()
| 55 | } |
| 56 | |
| 57 | async function collectCliMdEnvVarNames() { |
| 58 | const cliMdPath = join(rootDir, 'doc', 'api', 'cli.md'); |
| 59 | const fileStream = createReadStream(cliMdPath); |
| 60 | |
| 61 | let insideEnvVariablesSection = false; |
| 62 | |
| 63 | const rl = createInterface({ |
| 64 | input: fileStream, |
| 65 | }); |
| 66 | |
| 67 | const envVariableRE = /^### `(?<varName>[^`]*?)(?:=[^`]+)?`$/; |
| 68 | |
| 69 | const envVarNames = new Set(); |
| 70 | |
| 71 | for await (const line of rl) { |
| 72 | if (line.startsWith('## ')) { |
| 73 | if (insideEnvVariablesSection) { |
| 74 | // We were in the environment variables section and we're now exiting it, |
| 75 | // so there is no need to keep checking the remaining lines, |
| 76 | // we might as well close the stream and return |
| 77 | fileStream.close(); |
| 78 | return envVarNames; |
| 79 | } |
| 80 | |
| 81 | // We've just entered the options section |
| 82 | insideEnvVariablesSection = line === '## Environment variables'; |
| 83 | continue; |
| 84 | } |
| 85 | |
| 86 | if (insideEnvVariablesSection) { |
| 87 | const match = line.match(envVariableRE); |
| 88 | if (match) { |
| 89 | const { varName } = match.groups; |
| 90 | envVarNames.add(varName); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | return envVarNames; |
| 96 | } |
no test coverage detected
searching dependent graphs…