Skip to content

Commit f891820

Browse files
satrongantfu
andauthoredDec 1, 2022
fix: use globs option cannot resolve index.vue (#536)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent 48c3374 commit f891820

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/core/utils.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function stringifyComponentImport({ as: name, from: path, name: importNam
111111
}
112112

113113
export function getNameFromFilePath(filePath: string, options: ResolvedOptions): string {
114-
const { resolvedDirs, directoryAsNamespace, globalNamespaces, collapseSamePrefixes } = options
114+
const { resolvedDirs, directoryAsNamespace, globalNamespaces, collapseSamePrefixes, root } = options
115115

116116
const parsedFilePath = parse(slash(filePath))
117117

@@ -130,6 +130,10 @@ export function getNameFromFilePath(filePath: string, options: ResolvedOptions):
130130

131131
// set parent directory as filename if it is index
132132
if (filename === 'index' && !directoryAsNamespace) {
133+
// when use `globs` option, `resolvedDirs` will always empty, and `folders` will also empty
134+
if (isEmpty(folders))
135+
folders = parsedFilePath.dir.slice(root.length + 1).split('/').filter(Boolean)
136+
133137
filename = `${folders.slice(-1)[0]}`
134138
return filename
135139
}

0 commit comments

Comments
 (0)
Please sign in to comment.