mirror of
https://github.com/wassname/template.git
synced 2026-09-11 12:51:52 +08:00
2.1.0
Update render.js script; expose it as bin when used as npm dependency.
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const program = require('commander');
|
||||
const jsdom = require('jsdom');
|
||||
const { JSDOM } = jsdom;
|
||||
const transforms = require('../dist/transforms.v2.js');
|
||||
|
||||
program
|
||||
.version('0.0.1')
|
||||
.option('-i, --input <path>', 'path to input file.')
|
||||
.version('1.0.0')
|
||||
.description('Pre-renders distill articles for publication.')
|
||||
.usage('-i <input path> -o <output path>')
|
||||
.option('-i, --input_path <path>', 'path to input HTML file.')
|
||||
.option('-o, --output_path <path>', 'path to write rendered HTML file to.')
|
||||
.parse(process.argv);
|
||||
|
||||
const virtualConsole = new jsdom.VirtualConsole();
|
||||
@@ -27,5 +31,5 @@ JSDOM.fromFile(program.input, options).then(dom => {
|
||||
transforms.distillify(document, data);
|
||||
|
||||
const transformedHtml = dom.serialize();
|
||||
process.stdout.write(transformedHtml);
|
||||
fs.writeFileSync(program.output, transformedHtml);
|
||||
}).catch(console.error);
|
||||
Reference in New Issue
Block a user