Skip to content

Commit 7a4e93f

Browse files
authored
Ensure sidebars.ts and schemas are properly cleaned (#817)
* update vscode * ensure cleanup of sidebars.ts and switch to recursive delete schemas
1 parent 253e455 commit 7a4e93f

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

.vscode/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
"editor.defaultFormatter": "esbenp.prettier-vscode",
55
"editor.formatOnSave": true,
66
"editor.codeActionsOnSave": {
7-
"source.fixAll.eslint": true
7+
"source.fixAll.eslint": "explicit"
88
}
99
},
1010
"[typescript]": {
1111
"editor.defaultFormatter": "esbenp.prettier-vscode",
1212
"editor.formatOnSave": true,
1313
"editor.codeActionsOnSave": {
14-
"source.fixAll.eslint": true
14+
"source.fixAll.eslint": "explicit"
1515
}
1616
},
1717
"[typescriptreact]": {
1818
"editor.defaultFormatter": "esbenp.prettier-vscode",
1919
"editor.formatOnSave": true,
2020
"editor.codeActionsOnSave": {
21-
"source.fixAll.eslint": true
21+
"source.fixAll.eslint": "explicit"
2222
}
2323
},
2424
"[javascript][typescript][typescriptreact]": {

packages/docusaurus-plugin-openapi-docs/src/index.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,7 @@ custom_edit_url: null
476476
cwd: path.resolve(apiDir),
477477
deep: 1,
478478
});
479-
const schemaMdxFiles = await Globby(["*.schema.mdx"], {
480-
cwd: path.resolve(apiDir, "schemas"),
481-
deep: 1,
482-
});
483-
const sidebarFile = await Globby(["sidebar.js"], {
479+
const sidebarFile = await Globby(["sidebar.js", "sidebar.ts"], {
484480
cwd: path.resolve(apiDir),
485481
deep: 1,
486482
});
@@ -497,20 +493,17 @@ custom_edit_url: null
497493
})
498494
);
499495

500-
schemaMdxFiles.map((mdx) =>
501-
fs.unlink(`${apiDir}/schemas/${mdx}`, (err) => {
502-
if (err) {
503-
console.error(
504-
chalk.red(`Cleanup failed for "${apiDir}/schemas/${mdx}"`),
505-
chalk.yellow(err)
506-
);
507-
} else {
508-
console.log(
509-
chalk.green(`Cleanup succeeded for "${apiDir}/schemas/${mdx}"`)
510-
);
511-
}
512-
})
513-
);
496+
try {
497+
fs.rmSync(`${apiDir}/schemas`, { recursive: true });
498+
console.log(chalk.green(`Cleanup succeeded for "${apiDir}/schemas"`));
499+
} catch (err: any) {
500+
if (err.code !== "ENOENT") {
501+
console.error(
502+
chalk.red(`Cleanup failed for "${apiDir}/schemas"`),
503+
chalk.yellow(err)
504+
);
505+
}
506+
}
514507

515508
sidebarFile.map((sidebar) =>
516509
fs.unlink(`${apiDir}/${sidebar}`, (err) => {

0 commit comments

Comments
 (0)