(file: string)
| 19 | const KEY_VALUE = /^(.\w+):\s+(.*)$/; |
| 20 | |
| 21 | async function readFetch(file: string) { |
| 22 | const lines = await readLines(file); |
| 23 | if (lines[0] === '---') { |
| 24 | let row = 1; |
| 25 | while (row < lines.length && lines[row] !== '---') { |
| 26 | const line = lines[row++]; |
| 27 | const match = KEY_VALUE.exec(line); |
| 28 | if (match) { |
| 29 | const [_, key, value] = match; |
| 30 | if (key === 'fetch') return value; |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | return null; |
| 35 | } |
| 36 | |
| 37 | if (require.main === module) { |
| 38 | main(join(__dirname, '..', '..')); |