mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(resolver): resolvedPath/index.[ext] resolution (#4548)
This commit is contained in:
parent
6315bd71f3
commit
b413bc14fb
@ -69,16 +69,20 @@ export default class Resolver {
|
||||
resolvedPath = path
|
||||
}
|
||||
|
||||
// Check if resolvedPath exits
|
||||
if (fs.existsSync(resolvedPath)) {
|
||||
// Check if resolvedPath exits and is not a directory
|
||||
if (fs.existsSync(resolvedPath) && !fs.lstatSync(resolvedPath).isDirectory()) {
|
||||
return resolvedPath
|
||||
}
|
||||
|
||||
// Check if any resolvedPath.[ext] exists
|
||||
// Check if any resolvedPath.[ext] or resolvedPath/index.[ext] exists
|
||||
for (const ext of this.options.extensions) {
|
||||
if (fs.existsSync(resolvedPath + '.' + ext)) {
|
||||
return resolvedPath + '.' + ext
|
||||
}
|
||||
|
||||
if (fs.existsSync(resolvedPath + '/index.' + ext)) {
|
||||
return resolvedPath + '/index.' + ext
|
||||
}
|
||||
}
|
||||
|
||||
// Give up
|
||||
|
Loading…
Reference in New Issue
Block a user