Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 11 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,17 @@ 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 install({ pkgManager: ctx.pkgManager, cwd: ctx.cwd }).catch((e) => {
error('error', e);
process.exit(1);
ematipico marked this conversation as resolved.
Show resolved Hide resolved
}),
error(
'error',
`Dependencies failed to install, please run ${color.bold(
ctx.pkgManager + ' install'
)} to install them manually after setup.`
bluwy marked this conversation as resolved.
Show resolved Hide resolved
);
});
},
});
} 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