From 8c14bffbd9ea63bc4b4e9f9417352fdf4e7e65b4 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 12 May 2023 16:00:20 +0100 Subject: [PATCH] fix: don't exit the program if dependencies don't install (#7052) --- .changeset/empty-pillows-peel.md | 5 ++++ .../create-astro/src/actions/dependencies.ts | 26 ++++++++++++++----- packages/create-astro/src/messages.ts | 1 - 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 .changeset/empty-pillows-peel.md diff --git a/.changeset/empty-pillows-peel.md b/.changeset/empty-pillows-peel.md new file mode 100644 index 000000000..f76612d4a --- /dev/null +++ b/.changeset/empty-pillows-peel.md @@ -0,0 +1,5 @@ +--- +'create-astro': patch +--- + +Don't exit if dependencies fail to install diff --git a/packages/create-astro/src/actions/dependencies.ts b/packages/create-astro/src/actions/dependencies.ts index fe5e6f777..9735fe462 100644 --- a/packages/create-astro/src/actions/dependencies.ts +++ b/packages/create-astro/src/actions/dependencies.ts @@ -1,5 +1,5 @@ import type { Context } from './context'; - +import { color } from '@astrojs/cli-kit'; import { execa } from 'execa'; import { error, info, spinner, title } from '../messages.js'; @@ -25,12 +25,26 @@ export async function dependencies( await spinner({ start: `Dependencies installing with ${ctx.pkgManager}...`, end: 'Dependencies installed', - while: () => - install({ pkgManager: ctx.pkgManager, cwd: ctx.cwd }).catch((e) => { - // eslint-disable-next-line no-console + while: () => { + return Promise.reject('Unknown error').catch((e) => { error('error', e); - process.exit(1); - }), + error( + 'error', + `Dependencies failed to install, please run ${color.bold( + ctx.pkgManager + ' install' + )} to install them manually after setup.` + ); + }); + return install({ pkgManager: ctx.pkgManager, cwd: ctx.cwd }).catch((e) => { + error('error', e); + error( + 'error', + `Dependencies failed to install, please run ${color.bold( + ctx.pkgManager + ' install' + )} to install them manually after setup.` + ); + }); + }, }); } else { await info( diff --git a/packages/create-astro/src/messages.ts b/packages/create-astro/src/messages.ts index 9121ad60f..45bb7f96a 100644 --- a/packages/create-astro/src/messages.ts +++ b/packages/create-astro/src/messages.ts @@ -93,7 +93,6 @@ export const info = async (prefix: string, text: string) => { log(`${' '.repeat(5)} ${color.cyan('◼')} ${color.cyan(prefix)} ${color.dim(text)}`); } }; - export const error = async (prefix: string, text: string) => { if (stdout.columns < 80) { log(`${' '.repeat(5)} ${color.red('▲')} ${color.red(prefix)}`);