ignore.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. export namespace FileIgnore {
  2. const DEFAULT_PATTERNS = [
  3. // Dependencies
  4. "**/node_modules/**",
  5. "**/bower_components/**",
  6. "**/.pnpm-store/**",
  7. "**/vendor/**",
  8. // vcs
  9. "**/.git/**",
  10. // Build outputs
  11. "**/dist/**",
  12. "**/build/**",
  13. "**/out/**",
  14. "**/.next/**",
  15. "**/target/**", // Rust
  16. "**/bin/**",
  17. "**/obj/**", // .NET
  18. // Version control
  19. "**/.git/**",
  20. "**/.svn/**",
  21. "**/.hg/**",
  22. // IDE/Editor
  23. "**/.vscode/**",
  24. "**/.idea/**",
  25. "**/*.swp",
  26. "**/*.swo",
  27. // OS
  28. "**/.DS_Store",
  29. "**/Thumbs.db",
  30. // Logs & temp
  31. "**/logs/**",
  32. "**/tmp/**",
  33. "**/temp/**",
  34. "**/*.log",
  35. // Coverage/test outputs
  36. "**/coverage/**",
  37. "**/.nyc_output/**",
  38. ]
  39. const GLOBS = DEFAULT_PATTERNS.map((p) => new Bun.Glob(p))
  40. export function match(
  41. filepath: string,
  42. opts: {
  43. extra?: Bun.Glob[]
  44. },
  45. ) {
  46. const extra = opts.extra || []
  47. for (const glob of [...GLOBS, ...extra]) {
  48. if (glob.match(filepath)) return true
  49. }
  50. return false
  51. }
  52. }