no dependencies
This commit is contained in:
parent
93f01c6ebd
commit
d7e8646d1d
5 changed files with 1237 additions and 209 deletions
41
libs/args-parser.js
Normal file
41
libs/args-parser.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/30/19.
|
||||
*/
|
||||
|
||||
function Parse (argv) {
|
||||
// Removing node/bin and called script name
|
||||
argv = argv.slice(2);
|
||||
|
||||
// Returned object
|
||||
var args = {};
|
||||
|
||||
var argName, argValue;
|
||||
|
||||
// For each argument
|
||||
argv.forEach(function (arg, index) {
|
||||
// Seperate argument, for a key/value return
|
||||
arg = arg.split('=');
|
||||
|
||||
// Retrieve the argument name
|
||||
argName = arg[0];
|
||||
|
||||
// Remove "--" or "-"
|
||||
if (argName.indexOf('-') === 0) {
|
||||
argName = argName.slice(argName.slice(0, 2).lastIndexOf('-') + 1);
|
||||
}
|
||||
|
||||
// Associate defined value or initialize it to "true" state
|
||||
argValue = (arg.length === 2)
|
||||
? parseFloat(arg[1]).toString() === arg[1] // check if argument is valid number
|
||||
? +arg[1]
|
||||
: arg[1]
|
||||
: true;
|
||||
|
||||
// Finally add the argument to the args set
|
||||
args[argName] = argValue;
|
||||
});
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
module.exports = Parse;
|
1179
libs/js-beautifier.js
Normal file
1179
libs/js-beautifier.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue