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