Function
removeIgnoredFiles
(
dir: string,
includePaths: RegExp,
excludePaths: RegExp,
)
Source from the content-addressed store, hash-verified
| 3 | import klawSync from "klaw-sync" |
| 4 | |
| 5 | export function removeIgnoredFiles( |
| 6 | dir: string, |
| 7 | includePaths: RegExp, |
| 8 | excludePaths: RegExp, |
| 9 | ) { |
| 10 | klawSync(dir, { nodir: true }) |
| 11 | .map((item) => item.path.slice(`${dir}/`.length)) |
| 12 | .filter( |
| 13 | (relativePath) => |
| 14 | !relativePath.match(includePaths) || relativePath.match(excludePaths), |
| 15 | ) |
| 16 | .forEach((relativePath) => removeSync(join(dir, relativePath))) |
| 17 | } |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…