mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-12 03:38:07 +00:00
[skip release]
This commit is contained in:
parent
2b46d3e5f7
commit
85b53593fa
@ -69,22 +69,33 @@ export default class Resolver {
|
|||||||
resolvedPath = path
|
resolvedPath = path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isDirectory
|
||||||
|
|
||||||
// Check if resolvedPath exits and is not a directory
|
// Check if resolvedPath exits and is not a directory
|
||||||
if (fs.existsSync(resolvedPath) && !fs.lstatSync(resolvedPath).isDirectory()) {
|
if (fs.existsSync(resolvedPath)) {
|
||||||
|
isDirectory = fs.lstatSync(resolvedPath).isDirectory()
|
||||||
|
|
||||||
|
if (!isDirectory) {
|
||||||
return resolvedPath
|
return resolvedPath
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if any resolvedPath.[ext] or resolvedPath/index.[ext] exists
|
// Check if any resolvedPath.[ext] or resolvedPath/index.[ext] exists
|
||||||
for (const ext of this.options.extensions) {
|
for (const ext of this.options.extensions) {
|
||||||
if (fs.existsSync(resolvedPath + '.' + ext)) {
|
if (!isDirectory && fs.existsSync(resolvedPath + '.' + ext)) {
|
||||||
return resolvedPath + '.' + ext
|
return resolvedPath + '.' + ext
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(resolvedPath + '/index.' + ext)) {
|
if (isDirectory && fs.existsSync(resolvedPath + '/index.' + ext)) {
|
||||||
return resolvedPath + '/index.' + ext
|
return resolvedPath + '/index.' + ext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there's no index.[ext] we just return the directory path
|
||||||
|
if (isDirectory) {
|
||||||
|
return resolvedPath
|
||||||
|
}
|
||||||
|
|
||||||
// Give up
|
// Give up
|
||||||
throw new Error(`Cannot resolve "${path}" from "${resolvedPath}"`)
|
throw new Error(`Cannot resolve "${path}" from "${resolvedPath}"`)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user