mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
feat(builder): ignore option to function the same as .nuxtignore
(#7132)
This commit is contained in:
parent
f18e241f70
commit
51b5bf565b
@ -82,7 +82,8 @@ export default class Builder {
|
||||
this.bundleBuilder = this.getBundleBuilder(bundleBuilder)
|
||||
|
||||
this.ignore = new Ignore({
|
||||
rootDir: this.options.srcDir
|
||||
rootDir: this.options.srcDir,
|
||||
ignoreArray: this.options.ignore
|
||||
})
|
||||
}
|
||||
|
||||
@ -312,7 +313,6 @@ export default class Builder {
|
||||
async resolveFiles (dir, cwd = this.options.srcDir) {
|
||||
return this.ignore.filter(await glob(this.globPathWithExtensions(dir), {
|
||||
cwd,
|
||||
ignore: this.options.ignore,
|
||||
follow: this.options.build.followSymlinks
|
||||
}))
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ export default class Ignore {
|
||||
constructor (options) {
|
||||
this.rootDir = options.rootDir
|
||||
this.ignoreOptions = options.ignoreOptions
|
||||
this.ignoreArray = options.ignoreArray
|
||||
this.addIgnoresRules()
|
||||
}
|
||||
|
||||
@ -35,6 +36,12 @@ export default class Ignore {
|
||||
if (content) {
|
||||
this.ignore.add(content)
|
||||
}
|
||||
if (this.ignoreArray && this.ignoreArray.length > 0) {
|
||||
if (!this.ignore) {
|
||||
this.ignore = ignore(this.ignoreOptions)
|
||||
}
|
||||
this.ignore.add(this.ignoreArray)
|
||||
}
|
||||
}
|
||||
|
||||
filter (paths) {
|
||||
|
@ -102,7 +102,7 @@ describe('builder: builder generate', () => {
|
||||
expect(Glob).toBeCalledTimes(1)
|
||||
expect(Glob).toBeCalledWith(
|
||||
'/var/nuxt/dir/**/*.{vue,js}',
|
||||
{ cwd: '/var/nuxt/src', ignore: '/var/nuxt/ignore' }
|
||||
{ cwd: '/var/nuxt/src' }
|
||||
)
|
||||
expect(builder.ignore.filter).toBeCalledTimes(1)
|
||||
expect(builder.ignore.filter).toBeCalledWith('matched files')
|
||||
|
Loading…
Reference in New Issue
Block a user