fix: don't exit the program if dependencies don't install (#7052)
This commit is contained in:
parent
b064ca6539
commit
8c14bffbd9
3 changed files with 25 additions and 7 deletions
5
.changeset/empty-pillows-peel.md
Normal file
5
.changeset/empty-pillows-peel.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'create-astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Don't exit if dependencies fail to install
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Context } from './context';
|
import type { Context } from './context';
|
||||||
|
import { color } from '@astrojs/cli-kit';
|
||||||
import { execa } from 'execa';
|
import { execa } from 'execa';
|
||||||
import { error, info, spinner, title } from '../messages.js';
|
import { error, info, spinner, title } from '../messages.js';
|
||||||
|
|
||||||
|
@ -25,12 +25,26 @@ export async function dependencies(
|
||||||
await spinner({
|
await spinner({
|
||||||
start: `Dependencies installing with ${ctx.pkgManager}...`,
|
start: `Dependencies installing with ${ctx.pkgManager}...`,
|
||||||
end: 'Dependencies installed',
|
end: 'Dependencies installed',
|
||||||
while: () =>
|
while: () => {
|
||||||
install({ pkgManager: ctx.pkgManager, cwd: ctx.cwd }).catch((e) => {
|
return Promise.reject('Unknown error').catch((e) => {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
error('error', 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 {
|
} else {
|
||||||
await info(
|
await info(
|
||||||
|
|
|
@ -93,7 +93,6 @@ export const info = async (prefix: string, text: string) => {
|
||||||
log(`${' '.repeat(5)} ${color.cyan('◼')} ${color.cyan(prefix)} ${color.dim(text)}`);
|
log(`${' '.repeat(5)} ${color.cyan('◼')} ${color.cyan(prefix)} ${color.dim(text)}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const error = async (prefix: string, text: string) => {
|
export const error = async (prefix: string, text: string) => {
|
||||||
if (stdout.columns < 80) {
|
if (stdout.columns < 80) {
|
||||||
log(`${' '.repeat(5)} ${color.red('▲')} ${color.red(prefix)}`);
|
log(`${' '.repeat(5)} ${color.red('▲')} ${color.red(prefix)}`);
|
||||||
|
|
Loading…
Add table
Reference in a new issue