3 let commander = require('commander')
5 let jst = require('./jst')
8 .version('0.1.0', '-v, --version')
9 .option('-s, --signature <str>', 'function signature for --wrap', 'async (_require, _pathname, _root)')
10 .option('-b, --bare-returns', 'allow return in top level code', false)
11 .option('-o, --output <ast0|ast1|astring|uglify>', 'output raw or transformed AST, or via astring/UglifyJS', 'astring')
12 .option('-i, --indent <n>', 'indent per level (ast/astring only)', '2')
13 .option('-j, --initial-indent <n>', 'initial indent (astring only)', '0')
14 .option('-c, --compress', 'compress the logic (UglifyJS only)', true)
15 .option('-m, --mangle', 'mangle symbol names (UglifyJS only)', true)
16 .option('-w, --wrap', 'wrap as jst_server CommonJS module', false)
19 let text = fs.readFileSync(0, {encoding: 'utf-8'})
21 text = `module.exports=${commander.signature}=>{${text}}`
27 bare_returns: commander.bareReturns,
28 output: commander.output,
30 indent: parseInt(commander.indent)
33 indent: ' '.repeat(parseInt(commander.indent)),
34 startingIndentLevel: parseInt(commander.initialIndent)
37 compress: commander.compress,
38 mangle: commander.mangle,
39 output: {inline_script: false}