UNPKG

@jsenv/util

Version:

Set of functions often needed when using Node.js.

28 lines (22 loc) 397 B
export const getCommandArgument = (argv, name) => { let i = 0 while (i < argv.length) { const arg = argv[i] if (arg === name) { return { name, index: i, value: "", } } if (arg.startsWith(`${name}=`)) { return { name, index: i, value: arg.slice(`${name}=`.length), } } i++ } return null }