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