fix(kit): ignore negation when resolving ignore patterns

This commit is contained in:
Daniel Roe 2024-04-17 14:17:35 +01:00
parent 468ebbdf0b
commit e105fadd7e
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -28,6 +28,8 @@ export function isIgnored (pathname: string): boolean {
return !!(relativePath && nuxt._ignore.ignores(relativePath)) return !!(relativePath && nuxt._ignore.ignores(relativePath))
} }
const NEGATION_RE = /^(!?)(.*)$/
export function resolveIgnorePatterns (relativePath?: string): string[] { export function resolveIgnorePatterns (relativePath?: string): string[] {
const nuxt = tryUseNuxt() const nuxt = tryUseNuxt()
@ -48,7 +50,13 @@ export function resolveIgnorePatterns (relativePath?: string): string[] {
if (relativePath) { if (relativePath) {
// Map ignore patterns based on if they start with * or !* // Map ignore patterns based on if they start with * or !*
return nuxt._ignorePatterns.map(p => p[0] === '*' || (p[0] === '!' && p[1] === '*') ? p : relative(relativePath, resolve(nuxt.options.rootDir, p))) return nuxt._ignorePatterns.map(p => {
const [_, negation = '', pattern] = p.match(NEGATION_RE) || []
if (pattern[0] === '*') {
return p
}
return negation + relative(relativePath, resolve(nuxt.options.rootDir, pattern || p))
})
} }
return nuxt._ignorePatterns return nuxt._ignorePatterns