@@ -99,26 +99,29 @@ async function generateToc() {
99
99
) ;
100
100
}
101
101
}
102
- await spawn (
103
- 'yarn' ,
104
- [
105
- 'api-documenter-devsite' ,
106
- 'toc' ,
107
- '--input' ,
108
- 'temp' ,
109
- '-p' ,
110
- '/docs/reference/js' ,
111
- '-j'
112
- ] ,
113
- { stdio : 'inherit' }
114
- ) ;
115
- console . log ( `Restoring excluded packages' json files.` ) ;
116
- for ( const excludedPackage of EXCLUDED_PACKAGES ) {
117
- if ( fs . existsSync ( `${ projectRoot } /temp/${ excludedPackage } .skip` ) ) {
118
- fs . renameSync (
119
- `${ projectRoot } /temp/${ excludedPackage } .skip` ,
120
- `${ projectRoot } /temp/${ excludedPackage } .api.json`
121
- ) ;
102
+ try {
103
+ await spawn (
104
+ 'yarn' ,
105
+ [
106
+ 'api-documenter-devsite' ,
107
+ 'toc' ,
108
+ '--input' ,
109
+ 'temp' ,
110
+ '-p' ,
111
+ '/docs/reference/js' ,
112
+ '-j'
113
+ ] ,
114
+ { stdio : 'inherit' }
115
+ ) ;
116
+ } finally {
117
+ console . log ( `Restoring excluded packages' json files.` ) ;
118
+ for ( const excludedPackage of EXCLUDED_PACKAGES ) {
119
+ if ( fs . existsSync ( `${ projectRoot } /temp/${ excludedPackage } .skip` ) ) {
120
+ fs . renameSync (
121
+ `${ projectRoot } /temp/${ excludedPackage } .skip` ,
122
+ `${ projectRoot } /temp/${ excludedPackage } .api.json`
123
+ ) ;
124
+ }
122
125
}
123
126
}
124
127
}
@@ -131,6 +134,7 @@ async function generateDocs(
131
134
const outputFolder = forDevsite ? 'docs-devsite' : 'docs' ;
132
135
const command = forDevsite ? 'api-documenter-devsite' : 'api-documenter' ;
133
136
137
+ console . log ( `Temporarily modifying auth api-extractor.json for docgen.` ) ;
134
138
// Use a special d.ts file for auth for doc gen only.
135
139
const authApiConfigOriginal = fs . readFileSync (
136
140
`${ projectRoot } /packages/auth/api-extractor.json` ,
@@ -145,45 +149,49 @@ async function generateDocs(
145
149
`"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.d.ts"` ,
146
150
`"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.doc.d.ts"`
147
151
) ;
148
- fs . writeFileSync (
149
- `${ projectRoot } /packages/auth/api-extractor.json` ,
150
- authApiConfigModified
151
- ) ;
152
152
153
- if ( skipBuild ) {
154
- await spawn ( 'yarn' , [ 'api-report' ] , {
155
- stdio : 'inherit'
156
- } ) ;
157
- } else {
158
- // api-report is run as part of every build
159
- await spawn (
160
- 'yarn' ,
161
- [
162
- 'lerna' ,
163
- 'run' ,
164
- '--scope' ,
165
- '@firebase/*' ,
166
- '--ignore' ,
167
- '@firebase/*-compat' ,
168
- 'build'
169
- ] ,
170
- {
153
+ try {
154
+ fs . writeFileSync (
155
+ `${ projectRoot } /packages/auth/api-extractor.json` ,
156
+ authApiConfigModified
157
+ ) ;
158
+
159
+ if ( skipBuild ) {
160
+ await spawn ( 'yarn' , [ 'api-report' ] , {
171
161
stdio : 'inherit'
172
- }
162
+ } ) ;
163
+ } else {
164
+ // api-report is run as part of every build
165
+ await spawn (
166
+ 'yarn' ,
167
+ [
168
+ 'lerna' ,
169
+ 'run' ,
170
+ '--scope' ,
171
+ '@firebase/*' ,
172
+ '--ignore' ,
173
+ '@firebase/*-compat' ,
174
+ 'build'
175
+ ] ,
176
+ {
177
+ stdio : 'inherit'
178
+ }
179
+ ) ;
180
+ }
181
+ } finally {
182
+ console . log ( `Restoring original auth api-extractor.json contents.` ) ;
183
+ // Restore original auth api-extractor.json contents.
184
+ fs . writeFileSync (
185
+ `${ projectRoot } /packages/auth/api-extractor.json` ,
186
+ authApiConfigOriginal
187
+ ) ;
188
+ // Restore original auth.api.md
189
+ fs . writeFileSync (
190
+ `${ projectRoot } /common/api-review/auth.api.md` ,
191
+ authApiReportOriginal
173
192
) ;
174
193
}
175
194
176
- // Restore original auth api-extractor.json contents.
177
- fs . writeFileSync (
178
- `${ projectRoot } /packages/auth/api-extractor.json` ,
179
- authApiConfigOriginal
180
- ) ;
181
- // Restore original auth.api.md
182
- fs . writeFileSync (
183
- `${ projectRoot } /common/api-review/auth.api.md` ,
184
- authApiReportOriginal
185
- ) ;
186
-
187
195
if ( ! fs . existsSync ( tmpDir ) ) {
188
196
fs . mkdirSync ( tmpDir ) ;
189
197
}
0 commit comments