Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 40 lines (33 sloc) 895 Bytes
#!/usr/bin/env node
var fs = require('fs');
var argv = require('optimist').argv;
var compileEmberTemplate = require('ember-precompile');
var usage = '\n \
Precompile handlebar templates for Ember.js.\n \
Usage: ' + argv.$0 + ' template...\n\n \
Options:\n \
-b, --base-dir Base directory\n \
-f, --output Output File\n'
function main(){
if ((argv.h)||(argv.help)) {
console.log(usage);
process.exit(0);
}
var inputFiles = argv._;
var outputFile = argv.output || argv.f;
var baseDir = argv.b || null;
if (outputFile) {
// create a blank output file
fs.writeFileSync(outputFile, '', 'utf8');
function write(output){
fs.appendFileSync(outputFile, output + '\n', 'utf8');
}
}
else {
var write = console.log;
}
inputFiles.forEach(function(fileName){
write(compileEmberTemplate(fileName, { baseDir: baseDir }));
});
}
main();