| 12 | const { Pool } = pg; |
| 13 | |
| 14 | function parseArgs(argv) { |
| 15 | const args = {}; |
| 16 | |
| 17 | for (let index = 0; index < argv.length; index += 1) { |
| 18 | const token = argv[index]; |
| 19 | if (!token.startsWith('--')) { |
| 20 | continue; |
| 21 | } |
| 22 | |
| 23 | const [rawKey, inlineValue] = token.slice(2).split('='); |
| 24 | if (typeof inlineValue !== 'undefined') { |
| 25 | args[rawKey] = inlineValue; |
| 26 | continue; |
| 27 | } |
| 28 | |
| 29 | const nextToken = argv[index + 1]; |
| 30 | if (!nextToken || nextToken.startsWith('--')) { |
| 31 | args[rawKey] = true; |
| 32 | continue; |
| 33 | } |
| 34 | |
| 35 | args[rawKey] = nextToken; |
| 36 | index += 1; |
| 37 | } |
| 38 | |
| 39 | return args; |
| 40 | } |
| 41 | |
| 42 | function ensureCommand(command) { |
| 43 | const result = spawnSync(command, ['--version'], { |