Skip to content

Commit

Permalink
fix: don't exit the program if dependencies don't install (#7052)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored May 12, 2023
1 parent b064ca6 commit 8c14bff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-pillows-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Don't exit if dependencies fail to install
26 changes: 20 additions & 6 deletions packages/create-astro/src/actions/dependencies.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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);
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);
process.exit(1);
}),
error(
'error',
`Dependencies failed to install, please run ${color.bold(
ctx.pkgManager + ' install'
)} to install them manually after setup.`
);
});
},
});
} else {
await info(
Expand Down
1 change: 0 additions & 1 deletion packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`);
Expand Down

0 comments on commit 8c14bff

Please sign in to comment.