MXS-1300: Make MaxCtrl more like a library
All invocations into the common helper functions are now done through the `maxctrl` function. This allows the program arguments to be passed to the core as a parameter instead of reading them from global variables. This helps with the implicit initialization that was done when the yargs library was required which caused duplicated output. Refactored the core functions so that they only process the argument vector. The parsing of the argument vector is done in maxctrl.js where it is more appropriate.
This commit is contained in:
@ -13,4 +13,18 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
require('./core.js')(process.argv)
|
||||
var argv = process.argv
|
||||
|
||||
// Mangle the arguments if we are being called from the command line
|
||||
if (argv[0] == process.execPath) {
|
||||
argv.shift()
|
||||
// The first argument is always the script
|
||||
argv.shift()
|
||||
}
|
||||
|
||||
require('./core.js')(argv)
|
||||
.then(function(output){
|
||||
if (output.length > 0) {
|
||||
console.log(output)
|
||||
}
|
||||
}, console.log)
|
||||
|
||||
Reference in New Issue
Block a user