mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(builder): use path.resolve
for pages dir (#8832)
This commit is contained in:
parent
dcfb42b772
commit
8b1a70476a
@ -180,7 +180,7 @@ export default class Builder {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
!this._nuxtPages ||
|
!this._nuxtPages ||
|
||||||
await fsExtra.exists(path.join(this.options.srcDir, this.options.dir.pages))
|
await fsExtra.exists(path.resolve(this.options.srcDir, this.options.dir.pages))
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,13 @@ jest.mock('@nuxt/webpack')
|
|||||||
describe('builder: builder build', () => {
|
describe('builder: builder build', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
jest.spyOn(path, 'join').mockImplementation((...args) => `join(${args.join(', ')})`)
|
jest.spyOn(path, 'join').mockImplementation((...args) => `join(${args.join(', ')})`)
|
||||||
|
jest.spyOn(path, 'resolve').mockImplementation((...args) => `resolve(${args.join(', ')})`)
|
||||||
r.mockImplementation((...args) => `r(${args.join(', ')})`)
|
r.mockImplementation((...args) => `r(${args.join(', ')})`)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
path.join.mockRestore()
|
path.join.mockRestore()
|
||||||
|
path.resolve.mockRestore()
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -143,11 +145,12 @@ describe('builder: builder build', () => {
|
|||||||
await builder.validatePages()
|
await builder.validatePages()
|
||||||
|
|
||||||
expect(builder._nuxtPages).toEqual(true)
|
expect(builder._nuxtPages).toEqual(true)
|
||||||
expect(path.join).toBeCalledTimes(2)
|
expect(path.resolve).toBeCalledTimes(1)
|
||||||
expect(path.join).nthCalledWith(1, '/var/nuxt/src', '/var/nuxt/src/pages')
|
expect(path.resolve).nthCalledWith(1, '/var/nuxt/src', '/var/nuxt/src/pages')
|
||||||
expect(path.join).nthCalledWith(2, '/var/nuxt/src', '..', '/var/nuxt/src/pages')
|
expect(path.join).toBeCalledTimes(1)
|
||||||
|
expect(path.join).nthCalledWith(1, '/var/nuxt/src', '..', '/var/nuxt/src/pages')
|
||||||
expect(fsExtra.exists).toBeCalledTimes(2)
|
expect(fsExtra.exists).toBeCalledTimes(2)
|
||||||
expect(fsExtra.exists).nthCalledWith(1, 'join(/var/nuxt/src, /var/nuxt/src/pages)')
|
expect(fsExtra.exists).nthCalledWith(1, 'resolve(/var/nuxt/src, /var/nuxt/src/pages)')
|
||||||
expect(fsExtra.exists).nthCalledWith(2, 'join(/var/nuxt/src, .., /var/nuxt/src/pages)')
|
expect(fsExtra.exists).nthCalledWith(2, 'join(/var/nuxt/src, .., /var/nuxt/src/pages)')
|
||||||
expect(builder._defaultPage).toEqual(true)
|
expect(builder._defaultPage).toEqual(true)
|
||||||
expect(consola.warn).toBeCalledTimes(1)
|
expect(consola.warn).toBeCalledTimes(1)
|
||||||
@ -168,11 +171,10 @@ describe('builder: builder build', () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(builder._nuxtPages).toEqual(true)
|
expect(builder._nuxtPages).toEqual(true)
|
||||||
expect(path.join).toBeCalledTimes(2)
|
expect(path.resolve).nthCalledWith(1, '/var/nuxt/src', '/var/nuxt/src/pages')
|
||||||
expect(path.join).nthCalledWith(1, '/var/nuxt/src', '/var/nuxt/src/pages')
|
expect(path.join).nthCalledWith(1, '/var/nuxt/src', '..', '/var/nuxt/src/pages')
|
||||||
expect(path.join).nthCalledWith(2, '/var/nuxt/src', '..', '/var/nuxt/src/pages')
|
|
||||||
expect(fsExtra.exists).toBeCalledTimes(2)
|
expect(fsExtra.exists).toBeCalledTimes(2)
|
||||||
expect(fsExtra.exists).nthCalledWith(1, 'join(/var/nuxt/src, /var/nuxt/src/pages)')
|
expect(fsExtra.exists).nthCalledWith(1, 'resolve(/var/nuxt/src, /var/nuxt/src/pages)')
|
||||||
expect(fsExtra.exists).nthCalledWith(2, 'join(/var/nuxt/src, .., /var/nuxt/src/pages)')
|
expect(fsExtra.exists).nthCalledWith(2, 'join(/var/nuxt/src, .., /var/nuxt/src/pages)')
|
||||||
expect(builder._defaultPage).toBeUndefined()
|
expect(builder._defaultPage).toBeUndefined()
|
||||||
})
|
})
|
||||||
@ -198,10 +200,10 @@ describe('builder: builder build', () => {
|
|||||||
await builder.validatePages()
|
await builder.validatePages()
|
||||||
|
|
||||||
expect(builder._nuxtPages).toEqual(true)
|
expect(builder._nuxtPages).toEqual(true)
|
||||||
expect(path.join).toBeCalledTimes(1)
|
expect(path.resolve).toBeCalledTimes(1)
|
||||||
expect(path.join).toBeCalledWith('/var/nuxt/src', '/var/nuxt/src/pages')
|
expect(path.resolve).toBeCalledWith('/var/nuxt/src', '/var/nuxt/src/pages')
|
||||||
expect(fsExtra.exists).toBeCalledTimes(1)
|
expect(fsExtra.exists).toBeCalledTimes(1)
|
||||||
expect(fsExtra.exists).toBeCalledWith('join(/var/nuxt/src, /var/nuxt/src/pages)')
|
expect(fsExtra.exists).toBeCalledWith('resolve(/var/nuxt/src, /var/nuxt/src/pages)')
|
||||||
expect(builder._defaultPage).toBeUndefined()
|
expect(builder._defaultPage).toBeUndefined()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user