Skip to content

Commit

Permalink
misc(create): Ignore errors removing directory after download failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Genteure committed Oct 15, 2023
1 parent 2f9e208 commit ede7ae2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/create-astro/src/actions/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ export default async function copyTemplate(tmpl: string, ctx: Context) {
dir: '.',
});
} catch (err: any) {
fs.rmdirSync(ctx.cwd);
try {
fs.rmdirSync(ctx.cwd);
} catch (_) {
// Ignore any errors thrown while removing the directory,
// make sure we throw the original error based on the logic below.
}
if (err.message.includes('404')) {
throw new Error(`Template ${color.reset(tmpl)} ${color.dim('does not exist!')}`);
} else {
Expand Down

0 comments on commit ede7ae2

Please sign in to comment.