diff options
author | 2023-03-27 17:46:00 -0400 | |
---|---|---|
committer | 2023-03-27 17:46:00 -0400 | |
commit | c13d428a7804b5b9809dbea94a1b17c36714a1e1 (patch) | |
tree | 094c5d22221264195d92eac3a294d1e33c4db602 | |
parent | c853ffc6067cf1d4e877b87221c800f6447d459a (diff) | |
download | astro-c13d428a7804b5b9809dbea94a1b17c36714a1e1.tar.gz astro-c13d428a7804b5b9809dbea94a1b17c36714a1e1.tar.zst astro-c13d428a7804b5b9809dbea94a1b17c36714a1e1.zip |
Revert accidental create-astro fix
-rw-r--r-- | packages/create-astro/src/actions/template.ts | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts index aa0363694..4f7e751e9 100644 --- a/packages/create-astro/src/actions/template.ts +++ b/packages/create-astro/src/actions/template.ts @@ -35,13 +35,8 @@ export async function template(ctx: Pick<Context, 'template' | 'prompt' | 'dryRu while: () => copyTemplate(ctx.template!, ctx as Context).catch((e) => { // eslint-disable-next-line no-console - if (e instanceof Error) { - error('error', e.message); - process.exit(1); - } else { - error('error', 'Unable to clone template.'); - process.exit(1); - } + error('error', e); + process.exit(1); }), }); } else { @@ -86,18 +81,11 @@ export default async function copyTemplate(tmpl: string, ctx: Context) { } catch (err: any) { fs.rmdirSync(ctx.cwd); if (err.message.includes('404')) { - throw new Error(`Template ${color.reset(tmpl)} ${color.dim('does not exist!')}`); + await error('Error', `Template ${color.reset(tmpl)} ${color.dim('does not exist!')}`); } else { - throw new Error(err.message); + console.error(err.message); } - } - - // It's possible the repo exists (ex. `withastro/astro`), - // But the template route is invalid (ex. `withastro/astro/examples/DNE`). - // `giget` doesn't throw for this case, - // so check if the directory is still empty as a heuristic. - if (fs.readdirSync(ctx.cwd).length === 0) { - throw new Error(`Template ${color.reset(tmpl)} ${color.dim('is empty!')}`); + ctx.exit(1); } // Post-process in parallel |