Skip to content

Commit

Permalink
fix: added onError functionality to spinner (#9048)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
skirianov and sarah11918 authored Nov 10, 2023
1 parent 5db28e9 commit 1e97708
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-experts-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Fixes an issue where a successful "Dependencies installed" message is displayed even when installing dependencies fails.
2 changes: 1 addition & 1 deletion packages/create-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"//a": "MOST PACKAGES SHOULD GO IN DEV_DEPENDENCIES! THEY WILL BE BUNDLED.",
"//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
"dependencies": {
"@astrojs/cli-kit": "^0.3.0",
"@astrojs/cli-kit": "^0.3.1",
"giget": "1.1.2"
},
"devDependencies": {
Expand Down
19 changes: 9 additions & 10 deletions packages/create-astro/src/actions/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ export async function dependencies(
await spinner({
start: `Installing dependencies with ${ctx.packageManager}...`,
end: 'Dependencies installed',
while: () => {
return install({ packageManager: ctx.packageManager, cwd: ctx.cwd }).catch((e) => {
error('error', e);
error(
'error',
`Dependencies failed to install, please run ${color.bold(
ctx.packageManager + ' install'
)} to install them manually after setup.`
);
});
onError: (e) => {
error('error', e);
error(
'error',
`Dependencies failed to install, please run ${color.bold(
ctx.packageManager + ' install'
)} to install them manually after setup.`
);
},
while: () => install({ packageManager: ctx.packageManager, cwd: ctx.cwd }),
});
} else {
await info(
Expand Down
1 change: 1 addition & 0 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function say(messages: string | string[], { clear = false, hat = ''
export async function spinner(args: {
start: string;
end: string;
onError?: (error: any) => void;
while: (...args: any) => Promise<any>;
}) {
await load(args, { stdout });
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e97708

Please sign in to comment.