Skip to content

Commit 5f28cb9

Browse files
committed
Use separate patterns for delete and copy dirs
1 parent c64f173 commit 5f28cb9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

scripts/docgen/docgen.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,16 @@ async function generateDocs(
198198
`"mainEntryPointFilePath": "<projectFolder>/dist/esm/index.doc.d.ts"`
199199
);
200200

201-
// TODO: Throw error if path doesn't exist once all packages add markdown support.
202-
const apiJsonDirectories = (
201+
/**
202+
* Exclude compat as this script is only for modular docgen.
203+
*/
204+
const packageDirectories = (
203205
await mapWorkspaceToPackages([`${projectRoot}/packages/*`])
204-
).filter(
205-
path => fs.existsSync(join(path, 'temp')) && !path.includes('-compat')
206-
);
206+
).filter(path => fs.existsSync(path) && !path.includes('-compat'));
207207

208208
try {
209209
console.log(`Deleting old temp directories in each package.`);
210-
for (const dir of apiJsonDirectories) {
210+
for (const dir of packageDirectories) {
211211
fs.rmSync(join(dir, 'temp'), { recursive: true, force: true });
212212
}
213213

@@ -259,17 +259,19 @@ async function generateDocs(
259259

260260
fs.mkdirSync(tmpDir);
261261

262+
const apiJsonDirectories = packageDirectories
263+
.map(path => join(path, 'temp'))
264+
.filter(path => fs.existsSync(path));
262265
for (const dir of apiJsonDirectories) {
263-
const pkgTmpDir = join(dir, 'temp');
264266
const paths = await new Promise<string[]>(resolve =>
265-
glob(`${pkgTmpDir}/*.api.json`, (err, paths) => {
267+
glob(`${dir}/*.api.json`, (err, paths) => {
266268
if (err) throw err;
267269
resolve(paths);
268270
})
269271
);
270272

271273
if (paths.length === 0) {
272-
throw Error(`*.api.json file is missing in ${pkgTmpDir}`);
274+
throw Error(`*.api.json file is missing in ${dir}`);
273275
}
274276

275277
// there will be only 1 api.json file

0 commit comments

Comments
 (0)