@@ -10,31 +10,25 @@ const debug = Debug('vue-i18n-locale-message:reflector')
10
10
11
11
export default function reflectLocaleMessageMeta ( basePath : string , components : SFCFileInfo [ ] ) : LocaleMessageMeta [ ] {
12
12
return components . map ( target => {
13
- const desc = parse ( {
13
+ const { customBlocks } = parse ( {
14
14
source : target . content ,
15
15
filename : target . path ,
16
16
compiler : compiler as VueTemplateCompiler
17
17
} )
18
- const { contentPath, component, hierarchy } = parsePath ( basePath , target . path )
19
- return {
20
- contentPath,
21
- blocks : desc . customBlocks ,
22
- component,
23
- hierarchy
24
- }
18
+ return { ...parsePath ( basePath , target . path ) , blocks : customBlocks }
25
19
} )
26
20
}
27
21
28
22
function parsePath ( basePath : string , targetPath : string ) {
29
- const parsed = path . parse ( targetPath )
23
+ const { dir , name } = path . parse ( targetPath )
30
24
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31
- const [ _ , target ] = parsed . dir . split ( basePath )
25
+ const [ _ , target ] = dir . split ( basePath )
32
26
const parsedTargetPath = target . split ( path . sep )
33
27
parsedTargetPath . shift ( )
34
- debug ( `parsePath: contentPath = ${ targetPath } , component = ${ parsed . name } , messageHierarchy = ${ parsedTargetPath } ` )
28
+ debug ( `parsePath: contentPath = ${ targetPath } , component = ${ name } , messageHierarchy = ${ parsedTargetPath } ` )
35
29
return {
36
30
contentPath : targetPath ,
37
- component : parsed . name ,
38
- hierarchy : [ ...parsedTargetPath , parsed . name ]
31
+ component : name ,
32
+ hierarchy : [ ...parsedTargetPath , name ]
39
33
}
40
34
}
0 commit comments