Skip to content

Commit

Permalink
fix(core): join with os native sep in resolver (#7131)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored and pooya parsa committed Mar 31, 2020
1 parent 8d35595 commit 487c13e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
8 changes: 5 additions & 3 deletions packages/core/test/resolver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 487c13e

Please sign in to comment.