diff --git a/bin/render.js b/bin/render.js index bff3b25..6e893ec 100755 --- a/bin/render.js +++ b/bin/render.js @@ -10,26 +10,28 @@ const transforms = require('../dist/transforms.v2.js'); program .version('1.0.0') .description('Pre-renders distill articles for publication.') - .usage('-i -o ') - .option('-i, --input_path ', 'path to input HTML file.') - .option('-o, --output_path ', 'path to write rendered HTML file to.') + .usage('-i -o ') + .option('-i, --input-path ', 'path to input HTML file.') + .option('-o, --output-path ', 'path to write rendered HTML file to.') .parse(process.argv); +console.warn(program); + const virtualConsole = new jsdom.VirtualConsole(); // omitJSDOMErrors as JSDOM routinely can't parse modern CSS virtualConsole.sendTo(console, { omitJSDOMErrors: true }); const options = { runScripts: 'outside-only', QuerySelector: true, virtualConsole: virtualConsole }; -JSDOM.fromFile(program.input, options).then(dom => { +JSDOM.fromFile(program.inputPath, options).then(dom => { const window = dom.window; const document = window.document; const data = new transforms.FrontMatter; - data.inputHTMLPath = program.input; // may be needed to resolve relative links! - data.inputDirectory = path.dirname(program.input); + data.inputHTMLPath = program.inputPath; // may be needed to resolve relative links! + data.inputDirectory = path.dirname(program.inputPath); transforms.render(document, data); transforms.distillify(document, data); const transformedHtml = dom.serialize(); - fs.writeFileSync(program.output, transformedHtml); + fs.writeFileSync(program.outputPath, transformedHtml); }).catch(console.error);