bin/espruino-cli.js
function makeJobFile(config) {
  var job = {"espruino":{}};
  // assign commandline values
  for (var key in args) {
    switch (key) {
      case 'job': // remove job itself, and others set internally from the results
      case 'espruinoPrefix':
      case 'espruinoPostfix':
        break;
      default: job[key] = args[key];  // otherwise just output each key: value
    }
    // write fields of Espruino.Config passed as config
    for (var k in config) { if (typeof config[k]!=='function') job.espruino[k] = config[k]; };
  }
  // name job file same as code file with json ending or default and save.
  var jobFile = isNextValidJS(args.file) ? args.file.slice(0,args.file.lastIndexOf('.'))+'.json' : "job.json";

  if (!fs.existsSync(jobFile)) {
    log("Creating job file "+JSON.stringify(jobFile));
    fs.writeFileSync(jobFile,JSON.stringify(job,null,2),{encoding:"utf8"});
  } else
    log("WARNING: File "+JSON.stringify(jobFile)+" already exists - not overwriting.");
}
function makeJobFile(config) {
  var job = {"espruino":{}};
  // assign commandline values
  for (var key in args) {
    switch (key) {
      case 'job': // remove job itself, and others set internally from the results
      case 'espruinoPrefix':
      case 'espruinoPostfix':
        break;
      default: job[key] = args[key];  // otherwise just output each key: value
    }
    // write fields of Espruino.Config passed as config
    for (var k in config) { if (typeof config[k]!=='function') job.espruino[k] = config[k]; };
  }
  // name job file same as code file with json ending or default and save.
  var jobFile = isNextValidJS(args.file) ? args.file.slice(0,args.file.lastIndexOf('.'))+'.json' : "job.json";

  if (!fs.existsSync(jobFile)) {
    log("Creating job file "+JSON.stringify(jobFile));
    fs.writeFileSync(jobFile,JSON.stringify(job,null,2),{encoding:"utf8"});
  } else
    log("WARNING: File "+JSON.stringify(jobFile)+" already exists - not overwriting.");
}
function makeJobFile ( config ) { var job = { "espruino" : { } } ; // assign commandline values for ( var key in args ) { switch ( key ) { case 'job' : // remove job itself, and others set internally from the results case 'espruinoPrefix' : case 'espruinoPostfix' : break ; default : job [ key ] = args [ key ] ; // otherwise just output each key: value } // write fields of Espruino.Config passed as config for ( var k in config ) { if ( typeof config [ k ] !== 'function' ) job . espruino [ k ] = config [ k ] ; } ; } // name job file same as code file with json ending or default and save. var jobFile = isNextValidJS ( args . file ) ? args . file . slice ( 0 , args . file . lastIndexOf ( '.' ) ) + '.json' : "job.json" ; if ( ! fs . existsSync ( jobFile ) ) { log ( "Creating job file " + JSON . stringify ( jobFile ) ) ; fs . writeFileSync ( jobFile , JSON . stringify ( job , null , 2 ) , { encoding : "utf8" } ) ; } else log ( "WARNING: File " + JSON . stringify ( jobFile ) + " already exists - not overwriting." ) ; }
create a job file from commandline settings
create a job file from commandline settings