(path: string, includeProjectFiles = true)
| 251 | const PROJECT_FILES = ['package.json'] |
| 252 | |
| 253 | export function createIgnore(path: string, includeProjectFiles = true) { |
| 254 | const ignoreList = existsSync(resolve(path, '.gitignore')) |
| 255 | ? ( |
| 256 | parseGitignore( |
| 257 | readFileSync(resolve(path, '.gitignore')), |
| 258 | ) as unknown as { patterns: Array<string> } |
| 259 | ).patterns |
| 260 | : [] |
| 261 | const ig = ignore().add(ignoreList) |
| 262 | return (filePath: string) => { |
| 263 | const fileName = basename(filePath) |
| 264 | if ( |
| 265 | IGNORE_FILES.includes(fileName) || |
| 266 | (includeProjectFiles && PROJECT_FILES.includes(fileName)) |
| 267 | ) { |
| 268 | return true |
| 269 | } |
| 270 | const nameWithoutDotSlash = fileName.replace(/^\.\//, '') |
| 271 | return ig.ignores(nameWithoutDotSlash) |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | export function cleanUpFiles( |
| 276 | files: Record<string, string>, |
no test coverage detected