fix: don't exit the program if dependencies don't install (#7052)

This commit is contained in:
Emanuele Stoppa 2023-05-12 16:00:20 +01:00 committed by GitHub
parent b064ca6539
commit 8c14bffbd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 7 deletions

View file

@ -0,0 +1,5 @@
---
'create-astro': patch
---
Don't exit if dependencies fail to install

View file

@ -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(

View file

@ -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)}`);