yamlw
Version: 
A task to output YAML or JSON. Take build variables and write them to the build directory. Updates existing files or create them from scratch.
40 lines (29 loc) • 1.13 kB
JavaScript
// (c) 2018 Jordan Knight (jakkaj@gmail.com)
// This code is licensed under MIT license (see LICENSE.txt for details)
//example:
//yw -f samples/sample2.yaml --set "build.number=23,something.else='skdlfjlksdf'"
var program = require('commander');
var yamlwriter = require('./yamlw');
program
    .version('0.1.0')
    .option('-d, --dryrun', "Don't save the output, just print it on screen")
    .option('-f, --file [file]', 'The file to load or create')
    .option('-s, --set [options]', 'Variables to set separated by commas - e.g. "build=true,system.image.version=12"')
    .parse(process.argv);
if (!program.file) {
    console.log("Please pass in a file with the -f or --file argument");
    process.exit(1);
}
if (!program.set) {
    console.log('Please pass in variables with the -s or --set argument. Variables to set separated by commas - e.g. "build=true,system.image.version=12"');
    process.exit(1);
}
var file = program.file;
var set = program.set;
var dry = program.dryrun;
if (dry) {
    console.log("Doing a dry run");
}
var result = yamlwriter(file, dry, set);
console.log(result);