* Extract the value following a flag from the args array. * E.g. getFlagValue(['--port', '9000', '--host', '0.0.0.0'], '--port') => '9000'
(args, flag)
| 785 | * E.g. getFlagValue(['--port', '9000', '--host', '0.0.0.0'], '--port') => '9000' |
| 786 | */ |
| 787 | function getFlagValue(args, flag) { |
| 788 | const idx = args.indexOf(flag); |
| 789 | if (idx === -1 || idx + 1 >= args.length) return null; |
| 790 | return args[idx + 1]; |
| 791 | } |