(args, index, prefix)
| 1 | const DEFAULT_PORT = 3000 |
| 2 | |
| 3 | function readPortValue(args, index, prefix) { |
| 4 | const arg = args[index] |
| 5 | |
| 6 | if (arg.includes('=')) { |
| 7 | return arg.split('=')[1] |
| 8 | } |
| 9 | |
| 10 | if (arg.startsWith(prefix) && arg.length > prefix.length) { |
| 11 | return arg.slice(prefix.length) |
| 12 | } |
| 13 | |
| 14 | return args[index + 1] |
| 15 | } |
| 16 | |
| 17 | function parsePort(args = process.argv.slice(2), defaultPort = DEFAULT_PORT) { |
| 18 | for (let index = 0; index < args.length; index += 1) { |