Cut a trailing comment from a YAML line: the first `#` outside quotes after a space.
(line: string)
| 323 | |
| 324 | /** Cut a trailing comment from a YAML line: the first `#` outside quotes after a space. */ |
| 325 | function withoutYamlComment(line: string): string { |
| 326 | let quote = ''; |
| 327 | for (let i = 0; i < line.length; i++) { |
| 328 | const c = line[i]!; |
| 329 | if (quote) { |
| 330 | if (c === quote) quote = ''; |
| 331 | } else if (c === "'" || c === '"') quote = c; |
| 332 | else if (c === '#' && (i === 0 || /\s/.test(line[i - 1]!))) return line.slice(0, i); |
| 333 | } |
| 334 | return line; |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * Service definitions from a `*.services.yml` file. Line by line, as the routes are: |
no outgoing calls
no test coverage detected