@@ -15,6 +15,7 @@ interface ParseReturn {
15
15
dest : string ;
16
16
file : DirectoryFile ;
17
17
content : string ;
18
+ isEmpty : boolean ;
18
19
relativePathSrc : string ;
19
20
relativePathDest : string ;
20
21
}
@@ -34,16 +35,17 @@ export const parseFile = async (
34
35
const folderInSrc = join ( root , file . folder ) ;
35
36
36
37
let success = true ;
38
+ let isEmpty = false ;
37
39
let fileContent = '' ;
38
40
39
41
// parse file
40
42
try {
41
43
const content = await jsdoc2md . render ( {
42
44
files : [ `${ join ( folderInSrc , file . name + file . ext ) } ` ] ,
43
- configure : configPath ,
45
+ configure : join ( root , configPath ) ,
44
46
partial : [
45
- resolve ( __filename , '../../template/header.hbs' ) ,
46
- resolve ( __filename , '../../template/main.hbs' ) ,
47
+ resolve ( __filename , '../../../ template/header.hbs' ) ,
48
+ resolve ( __filename , '../../../ template/main.hbs' ) ,
47
49
...partials
48
50
]
49
51
} ) ;
@@ -53,7 +55,11 @@ export const parseFile = async (
53
55
file
54
56
) ;
55
57
56
- fileContent += content ;
58
+ if ( content ) {
59
+ fileContent += content ;
60
+ } else {
61
+ isEmpty = true ;
62
+ }
57
63
} catch ( e ) {
58
64
console . log ( e ) ;
59
65
success = false ;
@@ -62,6 +68,7 @@ export const parseFile = async (
62
68
return {
63
69
success,
64
70
file,
71
+ isEmpty,
65
72
relativePathDest,
66
73
relativePathSrc : file . folder ,
67
74
dest : folderInDest ,
@@ -87,6 +94,7 @@ export const parseVueFile = async (
87
94
} ;
88
95
89
96
let success = true ;
97
+ let isEmpty = false ;
90
98
let fileContent = '' ;
91
99
92
100
try {
@@ -102,7 +110,11 @@ export const parseVueFile = async (
102
110
file
103
111
) ;
104
112
105
- fileContent += data . content ;
113
+ if ( data . content ) {
114
+ fileContent += data . content ;
115
+ } else {
116
+ isEmpty = true ;
117
+ }
106
118
} catch ( e ) {
107
119
console . log ( e ) ;
108
120
success = false ;
@@ -111,6 +123,7 @@ export const parseVueFile = async (
111
123
return {
112
124
success,
113
125
file,
126
+ isEmpty,
114
127
relativePathDest,
115
128
relativePathSrc : file . folder ,
116
129
dest : folderInDest ,
@@ -122,7 +135,7 @@ export const writeContentToFile = async (parseData: ParseReturn | null, dest: st
122
135
const root = process . cwd ( ) ;
123
136
dest = join ( root , dest ) ;
124
137
125
- let type = parseData ?. success ? StatisticType . EMPTY : StatisticType . ERROR ;
138
+ let type = StatisticType . ERROR ;
126
139
127
140
try {
128
141
if ( parseData ?. content ) {
@@ -131,7 +144,7 @@ export const writeContentToFile = async (parseData: ParseReturn | null, dest: st
131
144
await mkdirp ( dest ) ;
132
145
await fs . writeFile ( path , parseData . content , 'utf-8' ) ;
133
146
134
- type = StatisticType . SUCCESS ;
147
+ type = parseData ?. isEmpty ? StatisticType . EMPTY : StatisticType . SUCCESS ;
135
148
}
136
149
137
150
return {
0 commit comments