* `ig` with buildOutputFolderUnderSrc applied on top of its patterns, * for every caller of the defaults alike. `projectRules` are the project's own * root ignore rules: a file they re-include by name, or whose folder they * re-include from the `build` folder down (`!src/build/`, the docu
(ig: Ignore, projectRules: Ignore | null)
| 413 | * opt-in), keeps every type, as it did before this rule. |
| 414 | */ |
| 415 | function excludeBuildOutputUnderSrc(ig: Ignore, projectRules: Ignore | null): Ignore { |
| 416 | const ignoredByPatterns = ig.ignores.bind(ig); |
| 417 | ig.ignores = (rel: string): boolean => { |
| 418 | if (ignoredByPatterns(rel)) return true; |
| 419 | const folder = buildOutputFolderUnderSrc(rel); |
| 420 | if (folder === null) return false; |
| 421 | if (!projectRules) return true; |
| 422 | // The file, then each folder above it up to the `build` folder. |
| 423 | for (let end = rel.length; end >= folder.length; end = rel.lastIndexOf('/', end - 2) + 1) { |
| 424 | if (projectRules.test(rel.slice(0, end)).unignored) return false; |
| 425 | } |
| 426 | return true; |
| 427 | }; |
| 428 | return ig; |
| 429 | } |
| 430 | |
| 431 | /** True if `buf` decodes as strict UTF-8 (no invalid byte sequences). */ |
| 432 | function isValidUtf8(buf: Buffer): boolean { |
no test coverage detected