Skip to content

Commit ae7742c

Browse files
committed
Make sure files always restored
1 parent 6e80a67 commit ae7742c

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

scripts/docgen/docgen.ts

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -145,45 +145,48 @@ async function generateDocs(
145145
`"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.d.ts"`,
146146
`"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.doc.d.ts"`
147147
);
148-
fs.writeFileSync(
149-
`${projectRoot}/packages/auth/api-extractor.json`,
150-
authApiConfigModified
151-
);
152148

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-
{
149+
try {
150+
fs.writeFileSync(
151+
`${projectRoot}/packages/auth/api-extractor.json`,
152+
authApiConfigModified
153+
);
154+
155+
if (skipBuild) {
156+
await spawn('yarn', ['api-report'], {
171157
stdio: 'inherit'
172-
}
158+
});
159+
} else {
160+
// api-report is run as part of every build
161+
await spawn(
162+
'yarn',
163+
[
164+
'lerna',
165+
'run',
166+
'--scope',
167+
'@firebase/*',
168+
'--ignore',
169+
'@firebase/*-compat',
170+
'build'
171+
],
172+
{
173+
stdio: 'inherit'
174+
}
175+
);
176+
}
177+
} finally {
178+
// Restore original auth api-extractor.json contents.
179+
fs.writeFileSync(
180+
`${projectRoot}/packages/auth/api-extractor.json`,
181+
authApiConfigOriginal
182+
);
183+
// Restore original auth.api.md
184+
fs.writeFileSync(
185+
`${projectRoot}/common/api-review/auth.api.md`,
186+
authApiReportOriginal
173187
);
174188
}
175189

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-
187190
if (!fs.existsSync(tmpDir)) {
188191
fs.mkdirSync(tmpDir);
189192
}

0 commit comments

Comments
 (0)