mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
fix(core): join with os native sep in resolver (#7131)
This commit is contained in:
parent
51b5bf565b
commit
9ef58fae63
@ -105,8 +105,9 @@ export default class Resolver {
|
||||
return resolvedPath + '.' + ext
|
||||
}
|
||||
|
||||
if (isDirectory && fs.existsSync(resolvedPath + '/index.' + ext)) {
|
||||
return resolvedPath + '/index.' + ext
|
||||
const resolvedPathwithIndex = join(resolvedPath, 'index.' + ext)
|
||||
if (isDirectory && fs.existsSync(resolvedPathwithIndex)) {
|
||||
return resolvedPathwithIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,14 @@ import { startsWithRootAlias, startsWithSrcAlias } from '@nuxt/utils'
|
||||
|
||||
import Resolver from '../src/resolver'
|
||||
|
||||
jest.mock('path')
|
||||
jest.mock('esm', () => jest.fn(() => jest.fn()))
|
||||
jest.mock('fs-extra')
|
||||
jest.mock('@nuxt/utils')
|
||||
|
||||
describe('core: resolver', () => {
|
||||
jest.spyOn(path, 'join')
|
||||
jest.spyOn(path, 'resolve')
|
||||
|
||||
describe.posix('core: resolver', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
@ -107,7 +109,7 @@ describe('core: resolver', () => {
|
||||
startsWithRootAlias.mockReturnValue(false)
|
||||
startsWithSrcAlias.mockReturnValue(false)
|
||||
|
||||
const aliasPath = { substr: jest.fn(p => String(p)) }
|
||||
const aliasPath = 'x'
|
||||
resolver.resolveAlias(aliasPath)
|
||||
|
||||
expect(path.resolve).toBeCalledTimes(1)
|
||||
|
Loading…
Reference in New Issue
Block a user