Skip to content

Commit f891820

Browse files
satrongantfu
andauthored
fix: use globs option cannot resolve index.vue (unplugin#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

Lines changed: 5 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy