var traceur = require('traceur'); var fs = require('fs');
if (process.argv.length < 5) {
throw "Usage: compile.js infile outfile options_as_json";
}
var infile = process.argv; var outfile = process.argv; var customOptions = JSON.parse(process.argv);
var contents = fs.readFileSync(infile).toString();
var result;
try {
result = traceur.compile(contents, customOptions, customOptions.filename, customOptions.filename);
} catch (error) {
console.error(error.join("\n")); process.exit(1);
}
fs.writeFileSync(outfile, result);