VersaWhiteboard/scripts/utils.js

21 lines
568 B
JavaScript
Raw Normal View History

function getArgs() {
2020-05-09 15:40:26 +02:00
const args = {};
process.argv.slice(2, process.argv.length).forEach((arg) => {
// long arg
if (arg.slice(0, 2) === "--") {
const longArg = arg.split("=");
args[longArg[0].slice(2, longArg[0].length)] = longArg[1];
}
// flags
else if (arg[0] === "-") {
const flags = arg.slice(1, arg.length).split("");
flags.forEach((flag) => {
args[flag] = true;
});
}
});
return args;
}
2020-05-09 15:40:26 +02:00
module.exports.getArgs = getArgs;