Skip to content

Instantly share code, notes, and snippets.

@hadeshe93
Created December 8, 2020 03:37
Show Gist options
  • Save hadeshe93/af6e694777f8da8154ff6fa6d622ae14 to your computer and use it in GitHub Desktop.
Save hadeshe93/af6e694777f8da8154ff6fa6d622ae14 to your computer and use it in GitHub Desktop.
Parse process.argv into object which matching the format you need.
const getWantedArgvObject = require('./parse-process-argv.js');
const argvObj = getWantedArgvObject(process.argv, {
'--deligate-comps': String,
// ...
});
const arg = require('arg');
module.exports = getWantedArgvObject = (processArgv, schema) => {
return arg(schema, { permissive: true, argv: processArgv });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment