Last active
August 14, 2016 16:01
-
-
Save apaleslimghost/17eea45ca987fd2acb3ea0cc3eba663b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const handlebars = require('handlebars'); | |
const hjson = require('hjson'); | |
const minimist = require('minimist'); | |
const fs = require('fs'); | |
const argv = minimist(process.argv.slice(2)); | |
console.assert(argv.t, '-t path/to/template.hbs is required'); | |
const template = fs.readFileSync(argv.t, 'utf8'); | |
const data = (argv.f ? [].concat(argv.f).map(f => fs.readFileSync(f, 'utf8')) : [].concat(argv._ || [])).reduce( | |
(data, src) => Object.assign(data, hjson.parse(src)), | |
{} | |
); | |
const output = argv.o ? fs.createWriteStream(argv.o) : process.stdout; | |
output.write(handlebars.compile(template)(data)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment