Skip to content

Commit

Permalink
fix: don't exit the program is dependencies don't install
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed May 10, 2023
1 parent a44e755 commit b702cb5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 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
15 changes: 9 additions & 6 deletions packages/create-astro/src/actions/dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Context } from './context';

import { execa } from 'execa';
import { error, info, spinner, title } from '../messages.js';
import { error, info, spinner, title, warn } from '../messages.js';

export async function dependencies(
ctx: Pick<Context, 'install' | 'yes' | 'prompt' | 'pkgManager' | 'cwd' | 'dryRun'>
Expand All @@ -25,12 +25,15 @@ 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);
}),
warn(
'warning',
'Dependencies failed to install, please install them manually after setup.'
);
});
},
});
} else {
await info(
Expand Down
9 changes: 9 additions & 0 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ export const info = async (prefix: string, text: string) => {
}
};

export const warn = async (prefix: string, text: string) => {
if (stdout.columns < 80) {
log(`${' '.repeat(5)} ${color.yellow('◼')} ${color.yellow(prefix)}`);
log(`${' '.repeat(9)}${color.dim(text)}`);
} else {
log(`${' '.repeat(5)} ${color.yellow('◼')} ${color.yellow(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 b702cb5

Please sign in to comment.