Skip to content

Commit 0ead6b8

Browse files
committed
cleanup long predicate
1 parent 27513b6 commit 0ead6b8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/core/resolve.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import assign from 'object-assign'
66
import fs from 'fs'
77
import { dirname, basename, join } from 'path'
88

9-
export const CASE_INSENSITIVE = fs.existsSync(join(__dirname, 'reSOLVE.js'))
9+
export const CASE_SENSITIVE_FS = !fs.existsSync(join(__dirname, 'reSOLVE.js'))
1010

1111
const fileExistsCache = new Map()
1212

@@ -26,6 +26,12 @@ function checkCache(cacheKey, { lifetime }) {
2626

2727
// http://stackoverflow.com/a/27382838
2828
function fileExistsWithCaseSync(filepath, cacheSettings) {
29+
// don't care if the FS is case-sensitive
30+
if (CASE_SENSITIVE_FS) return true
31+
32+
// null means it resolved to a builtin
33+
if (filepath === null) return true
34+
2935
const dir = dirname(filepath)
3036

3137
let result = checkCache(filepath, cacheSettings)
@@ -105,7 +111,7 @@ export function relative(modulePath, sourceFile, settings) {
105111
let { path: fullPath, found } = withResolver(resolver, config)
106112

107113
// resolvers imply file existence, this double-check just ensures the case matches
108-
if (found && CASE_INSENSITIVE && fullPath !== null && !fileExistsWithCaseSync(fullPath, cacheSettings)) {
114+
if (found && !fileExistsWithCaseSync(fullPath, cacheSettings)) {
109115
// reject resolved path
110116
fullPath = undefined
111117
}

0 commit comments

Comments
 (0)