@sprucelabs/path-resolver
Advanced tools
Comparing version 1.3.0 to 1.3.1-prerelease-dir-index.1
@@ -194,10 +194,25 @@ "use strict"; | ||
for (const candidate of candidates) { | ||
let pathIsDirectory = false; | ||
try { | ||
pathIsDirectory = fs_1.default.lstatSync(candidate).isDirectory(); | ||
} | ||
catch (e) { | ||
log_1.default.trace(e); | ||
} | ||
for (const ext of this.extensions) { | ||
const fullPath = candidate + ext; | ||
attemptedPaths.push(fullPath); | ||
if (fs_1.default.existsSync(fullPath)) { | ||
log_1.default.info(`${request} mapped to -> ${fullPath}`); | ||
this.pathCache[request] = fullPath; | ||
return fullPath; | ||
const pathsToAttempt = [fullPath]; | ||
// Check for index file if it's a path | ||
if (pathIsDirectory) { | ||
pathsToAttempt.push(path.join(candidate, `index${ext}`)); | ||
} | ||
for (let i = 0; i < pathsToAttempt.length; i += 1) { | ||
const pathToAttempt = pathsToAttempt[i]; | ||
attemptedPaths.push(pathToAttempt); | ||
if (fs_1.default.existsSync(pathToAttempt)) { | ||
log_1.default.info(`${request} mapped to -> ${pathToAttempt}`); | ||
this.pathCache[request] = pathToAttempt; | ||
return pathToAttempt; | ||
} | ||
} | ||
} | ||
@@ -204,0 +219,0 @@ } |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "1.3.0", | ||
"version": "1.3.1-prerelease-dir-index.1", | ||
"main": "./build/index.js", | ||
@@ -13,0 +13,0 @@ "types": "./build/index.d.ts", |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
43672
500
1