refactor: unwrap FileIgnore namespace + self-reexport (#22937)

This commit is contained in:
Kit Langton
2026-04-17 00:02:08 +00:00
committed by GitHub
parent 974fa1b8b1
commit 06d247c709
+70 -70
View File
@@ -1,81 +1,81 @@
import { Glob } from "@opencode-ai/shared/util/glob" import { Glob } from "@opencode-ai/shared/util/glob"
export namespace FileIgnore { const FOLDERS = new Set([
const FOLDERS = new Set([ "node_modules",
"node_modules", "bower_components",
"bower_components", ".pnpm-store",
".pnpm-store", "vendor",
"vendor", ".npm",
".npm", "dist",
"dist", "build",
"build", "out",
"out", ".next",
".next", "target",
"target", "bin",
"bin", "obj",
"obj", ".git",
".git", ".svn",
".svn", ".hg",
".hg", ".vscode",
".vscode", ".idea",
".idea", ".turbo",
".turbo", ".output",
".output", "desktop",
"desktop", ".sst",
".sst", ".cache",
".cache", ".webkit-cache",
".webkit-cache", "__pycache__",
"__pycache__", ".pytest_cache",
".pytest_cache", "mypy_cache",
"mypy_cache", ".history",
".history", ".gradle",
".gradle", ])
])
const FILES = [ const FILES = [
"**/*.swp", "**/*.swp",
"**/*.swo", "**/*.swo",
"**/*.pyc", "**/*.pyc",
// OS // OS
"**/.DS_Store", "**/.DS_Store",
"**/Thumbs.db", "**/Thumbs.db",
// Logs & temp // Logs & temp
"**/logs/**", "**/logs/**",
"**/tmp/**", "**/tmp/**",
"**/temp/**", "**/temp/**",
"**/*.log", "**/*.log",
// Coverage/test outputs // Coverage/test outputs
"**/coverage/**", "**/coverage/**",
"**/.nyc_output/**", "**/.nyc_output/**",
] ]
export const PATTERNS = [...FILES, ...FOLDERS] export const PATTERNS = [...FILES, ...FOLDERS]
export function match( export function match(
filepath: string, filepath: string,
opts?: { opts?: {
extra?: string[] extra?: string[]
whitelist?: string[] whitelist?: string[]
}, },
) { ) {
for (const pattern of opts?.whitelist || []) { for (const pattern of opts?.whitelist || []) {
if (Glob.match(pattern, filepath)) return false if (Glob.match(pattern, filepath)) return false
}
const parts = filepath.split(/[/\\]/)
for (let i = 0; i < parts.length; i++) {
if (FOLDERS.has(parts[i])) return true
}
const extra = opts?.extra || []
for (const pattern of [...FILES, ...extra]) {
if (Glob.match(pattern, filepath)) return true
}
return false
} }
const parts = filepath.split(/[/\\]/)
for (let i = 0; i < parts.length; i++) {
if (FOLDERS.has(parts[i])) return true
}
const extra = opts?.extra || []
for (const pattern of [...FILES, ...extra]) {
if (Glob.match(pattern, filepath)) return true
}
return false
} }
export * as FileIgnore from "./ignore"