Skip to content

Commit

Permalink
Ensure sidebars.ts and schemas are properly cleaned (#817)
Browse files Browse the repository at this point in the history
* update vscode

* ensure cleanup of sidebars.ts and switch to recursive delete schemas
  • Loading branch information
sserrata committed May 6, 2024
1 parent 253e455 commit 7a4e93f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
},
"[javascript][typescript][typescriptreact]": {
Expand Down
31 changes: 12 additions & 19 deletions packages/docusaurus-plugin-openapi-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,7 @@ custom_edit_url: null
cwd: path.resolve(apiDir),
deep: 1,
});
const schemaMdxFiles = await Globby(["*.schema.mdx"], {
cwd: path.resolve(apiDir, "schemas"),
deep: 1,
});
const sidebarFile = await Globby(["sidebar.js"], {
const sidebarFile = await Globby(["sidebar.js", "sidebar.ts"], {
cwd: path.resolve(apiDir),
deep: 1,
});
Expand All @@ -497,20 +493,17 @@ custom_edit_url: null
})
);

schemaMdxFiles.map((mdx) =>
fs.unlink(`${apiDir}/schemas/${mdx}`, (err) => {
if (err) {
console.error(
chalk.red(`Cleanup failed for "${apiDir}/schemas/${mdx}"`),
chalk.yellow(err)
);
} else {
console.log(
chalk.green(`Cleanup succeeded for "${apiDir}/schemas/${mdx}"`)
);
}
})
);
try {
fs.rmSync(`${apiDir}/schemas`, { recursive: true });
console.log(chalk.green(`Cleanup succeeded for "${apiDir}/schemas"`));
} catch (err: any) {
if (err.code !== "ENOENT") {
console.error(
chalk.red(`Cleanup failed for "${apiDir}/schemas"`),
chalk.yellow(err)
);
}
}

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

0 comments on commit 7a4e93f

Please sign in to comment.