mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-30 13:54:01 +00:00
72 lines
1.2 KiB
TypeScript
72 lines
1.2 KiB
TypeScript
import { sep } from "node:path"
|
|
|
|
export namespace FileIgnore {
|
|
const FOLDERS = new Set([
|
|
"node_modules",
|
|
"bower_components",
|
|
".pnpm-store",
|
|
"vendor",
|
|
"dist",
|
|
"build",
|
|
"out",
|
|
".next",
|
|
"target",
|
|
"bin",
|
|
"obj",
|
|
".git",
|
|
".svn",
|
|
".hg",
|
|
".vscode",
|
|
".idea",
|
|
".turbo",
|
|
".output",
|
|
"desktop",
|
|
".sst",
|
|
])
|
|
|
|
const FILES = [
|
|
"**/*.swp",
|
|
"**/*.swo",
|
|
|
|
// OS
|
|
"**/.DS_Store",
|
|
"**/Thumbs.db",
|
|
|
|
// Logs & temp
|
|
"**/logs/**",
|
|
"**/tmp/**",
|
|
"**/temp/**",
|
|
"**/*.log",
|
|
|
|
// Coverage/test outputs
|
|
"**/coverage/**",
|
|
"**/.nyc_output/**",
|
|
]
|
|
|
|
const FILE_GLOBS = FILES.map((p) => new Bun.Glob(p))
|
|
|
|
export function match(
|
|
filepath: string,
|
|
opts?: {
|
|
extra?: Bun.Glob[]
|
|
whitelist?: Bun.Glob[]
|
|
},
|
|
) {
|
|
for (const glob of opts?.whitelist || []) {
|
|
if (glob.match(filepath)) return false
|
|
}
|
|
|
|
const parts = filepath.split(sep)
|
|
for (let i = 0; i < parts.length; i++) {
|
|
if (FOLDERS.has(parts[i])) return true
|
|
}
|
|
|
|
const extra = opts?.extra || []
|
|
for (const glob of [...FILE_GLOBS, ...extra]) {
|
|
if (glob.match(filepath)) return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
}
|