mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Merge pull request #2594 from nuxt/feat/glob-ignore
options.ignore support
This commit is contained in:
commit
d90102e469
@ -274,7 +274,7 @@ module.exports = class Builder {
|
||||
if (existsSync(resolve(this.options.srcDir, 'layouts'))) {
|
||||
const layoutsFiles = await glob('layouts/**/*.{vue,js}', {
|
||||
cwd: this.options.srcDir,
|
||||
ignore: [`layouts/**/${this.options.ignorePrefix}*.{vue,js}`]
|
||||
ignore: this.options.ignore
|
||||
})
|
||||
let hasErrorLayout = false
|
||||
layoutsFiles.forEach(file => {
|
||||
@ -316,7 +316,7 @@ module.exports = class Builder {
|
||||
const files = {}
|
||||
;(await glob('pages/**/*.{vue,js}', {
|
||||
cwd: this.options.srcDir,
|
||||
ignore: [`pages/**/${this.options.ignorePrefix}*.{vue,js}`]
|
||||
ignore: this.options.ignore
|
||||
})).forEach(f => {
|
||||
const key = f.replace(/\.(js|vue)$/, '')
|
||||
if (/\.vue$/.test(f) || !files[key]) {
|
||||
|
@ -119,6 +119,14 @@ Options.from = function (_options) {
|
||||
options.debug = options.dev
|
||||
}
|
||||
|
||||
// Normalize ignore
|
||||
options.ignore = options.ignore ? [].concat(options.ignore) : []
|
||||
|
||||
// Append ignorePrefix glob to ignore
|
||||
if (typeof options.ignorePrefix === 'string') {
|
||||
options.ignore.push(`**/${options.ignorePrefix}*.*`)
|
||||
}
|
||||
|
||||
// Apply mode preset
|
||||
let modePreset =
|
||||
Options.modes[options.mode || 'universal'] || Options.modes['universal']
|
||||
@ -167,6 +175,9 @@ Options.defaults = {
|
||||
nuxtAppDir: resolve(__dirname, '../app'),
|
||||
modulesDir: ['node_modules'], // ~> relative to options.rootDir
|
||||
ignorePrefix: '-',
|
||||
ignore: [
|
||||
'**/*.test.*'
|
||||
],
|
||||
extensions: [],
|
||||
build: {
|
||||
analyze: false,
|
||||
|
@ -173,6 +173,12 @@ test.serial('/-ignored', async t => {
|
||||
t.true(error.response.body.includes('Cannot GET /-ignored'))
|
||||
})
|
||||
|
||||
test.serial('/ignored.test', async t => {
|
||||
const error = await t.throws(rp(url('/ignored.test')))
|
||||
t.true(error.statusCode === 404)
|
||||
t.true(error.response.body.includes('Cannot GET /ignored.test'))
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
test.after.always('Closing server', async t => {
|
||||
await server.close()
|
||||
|
@ -252,10 +252,7 @@ test('Content-Security-Policy Header', async t => {
|
||||
resolveWithFullResponse: true
|
||||
})
|
||||
// Verify functionality
|
||||
t.is(
|
||||
headers['content-security-policy'],
|
||||
"script-src 'self' 'sha256-BBvfKxDOoRM/gnFwke9u60HBZX3HUss/0lSI1sBRvOU='"
|
||||
)
|
||||
t.regex(headers['content-security-policy'], /script-src 'self' 'sha256-.*'/)
|
||||
})
|
||||
|
||||
test('/_nuxt/server-bundle.json should return 404', async t => {
|
||||
|
3
test/fixtures/basic/middleware/ignored.test.js
vendored
Normal file
3
test/fixtures/basic/middleware/ignored.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export default function () {
|
||||
throw new Error('Should be ignored')
|
||||
}
|
13
test/fixtures/basic/pages/ignored.test.vue
vendored
Normal file
13
test/fixtures/basic/pages/ignored.test.vue
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<template lang="html">
|
||||
<div class="error">
|
||||
Should be ignored
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css">
|
||||
</style>
|
3
test/fixtures/basic/store/ignored.test.js
vendored
Normal file
3
test/fixtures/basic/store/ignored.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export const state = () => ({
|
||||
error: 'Should be ignored'
|
||||
})
|
Loading…
Reference in New Issue
Block a user