commander
.version('0.1.0', '-v, --version')
.option('-i, --indent <n>', 'indent [2]', '2')
- .option('-j, --initial-indent <n>', 'initial indent [0]', '0')
+ .option('-j, --initial-indent <n>', 'initial indent level [0]', '0')
.option('-n, --name <str>', 'message for --wrap [page.jst]', 'page.jst')
- .option('-w, --wrap', 'wrap as jst_server template function', false)
+ .option('-w, --wrap', 'wrap as jst_server template function')
.parse(process.argv)
let indent = parseInt(commander.indent)
let initial_indent = parseInt(commander.initialIndent)
+let wrap = commander.wrap || false
let text = jstize(
fs.readFileSync(0, {encoding: 'utf-8'}),
{
indent: indent,
- initial_indent: initial_indent + commander.wrap ? indent : 0
+ initial_indent: initial_indent + wrap
}
)
-if (commander.wrap)
- text = `${' '.repeat(initial_indent)}return env => {
-${' '.repeat(initial_indent)} let _out = []
-${text}${' '.repeat(initial_indent)} _site.serve(env, 200, Buffer.from(_out.join('')), '${commander.name}')
-${' '.repeat(initial_indent)}}
+if (wrap)
+ text = `${' '.repeat(indent * initial_indent)}return async env => {
+${' '.repeat(indent * (initial_indent + 1))}let _out = []
+${text}${' '.repeat(indent * (initial_indent + 1))}_site.serve(env, 200, Buffer.from(_out.join('')), '${commander.name}')
+${' '.repeat(indent * initial_indent)}}
`
fs.writeSync(1, text, {encoding: 'utf-8'})