summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/tall-geese-end.md5
m---------packages/create-astro/grubby-group0
-rw-r--r--packages/create-astro/src/actions/dependencies.ts12
-rw-r--r--packages/create-astro/src/actions/git.ts8
-rw-r--r--packages/create-astro/src/actions/template.ts6
-rw-r--r--packages/create-astro/src/actions/typescript.ts6
6 files changed, 30 insertions, 7 deletions
diff --git a/.changeset/tall-geese-end.md b/.changeset/tall-geese-end.md
new file mode 100644
index 000000000..ba9c93481
--- /dev/null
+++ b/.changeset/tall-geese-end.md
@@ -0,0 +1,5 @@
+---
+'create-astro': patch
+---
+
+Improve error handling during tasks that display a spinner
diff --git a/packages/create-astro/grubby-group b/packages/create-astro/grubby-group
deleted file mode 160000
-Subproject 9a401ddf2e7896d7928eea910c61b5d5a29481a
diff --git a/packages/create-astro/src/actions/dependencies.ts b/packages/create-astro/src/actions/dependencies.ts
index 5991e958f..7195c81a5 100644
--- a/packages/create-astro/src/actions/dependencies.ts
+++ b/packages/create-astro/src/actions/dependencies.ts
@@ -1,7 +1,7 @@
import type { Context } from './context';
import { execa } from 'execa';
-import { info, spinner, title } from '../messages.js';
+import { info, error, spinner, title } from '../messages.js';
export async function dependencies(
ctx: Pick<Context, 'install' | 'yes' | 'prompt' | 'pkgManager' | 'cwd' | 'dryRun'>
@@ -25,7 +25,12 @@ export async function dependencies(
await spinner({
start: `Dependencies installing with ${ctx.pkgManager}...`,
end: 'Dependencies installed',
- while: () => install({ pkgManager: ctx.pkgManager, cwd: ctx.cwd }),
+ while: () =>
+ install({ pkgManager: ctx.pkgManager, cwd: ctx.cwd }).catch((e) => {
+ // eslint-disable-next-line no-console
+ error('error', e);
+ process.exit(1);
+ }),
});
} else {
await info(
@@ -38,7 +43,8 @@ export async function dependencies(
async function install({ pkgManager, cwd }: { pkgManager: string; cwd: string }) {
const installExec = execa(pkgManager, ['install'], { cwd });
return new Promise<void>((resolve, reject) => {
- installExec.on('error', (error) => reject(error));
+ setTimeout(() => reject(`Request timed out after one minute`), 60_000);
+ installExec.on('error', (e) => reject(e));
installExec.on('close', () => resolve());
});
}
diff --git a/packages/create-astro/src/actions/git.ts b/packages/create-astro/src/actions/git.ts
index 51a7e09c8..6949346fb 100644
--- a/packages/create-astro/src/actions/git.ts
+++ b/packages/create-astro/src/actions/git.ts
@@ -4,7 +4,7 @@ import type { Context } from './context';
import { color } from '@astrojs/cli-kit';
import { execa } from 'execa';
-import { info, spinner, title } from '../messages.js';
+import { info, spinner, error, title } from '../messages.js';
export async function git(ctx: Pick<Context, 'cwd' | 'git' | 'yes' | 'prompt' | 'dryRun'>) {
if (fs.existsSync(path.join(ctx.cwd, '.git'))) {
@@ -29,7 +29,11 @@ export async function git(ctx: Pick<Context, 'cwd' | 'git' | 'yes' | 'prompt' |
await spinner({
start: 'Git initializing...',
end: 'Git initialized',
- while: () => init({ cwd: ctx.cwd }),
+ while: () => init({ cwd: ctx.cwd }).catch((e) => {
+ // eslint-disable-next-line no-console
+ error('error', e);
+ process.exit(1);
+ }),
});
} else {
await info(
diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts
index e809005a2..164e33542 100644
--- a/packages/create-astro/src/actions/template.ts
+++ b/packages/create-astro/src/actions/template.ts
@@ -34,7 +34,11 @@ export async function template(
await spinner({
start: 'Template copying...',
end: 'Template copied',
- while: () => copyTemplate(ctx.template!, ctx as Context),
+ while: () => copyTemplate(ctx.template!, ctx as Context).catch((e) => {
+ // eslint-disable-next-line no-console
+ error('error', e);
+ process.exit(1);
+ }),
});
} else {
ctx.exit(1);
diff --git a/packages/create-astro/src/actions/typescript.ts b/packages/create-astro/src/actions/typescript.ts
index 24e9e8362..2cbbcf72a 100644
--- a/packages/create-astro/src/actions/typescript.ts
+++ b/packages/create-astro/src/actions/typescript.ts
@@ -61,7 +61,11 @@ export async function typescript(
await spinner({
start: 'TypeScript customizing...',
end: 'TypeScript customized',
- while: () => setupTypeScript(ts!, { cwd: ctx.cwd }),
+ while: () => setupTypeScript(ts!, { cwd: ctx.cwd }).catch((e) => {
+ // eslint-disable-next-line no-console
+ error('error', e);
+ process.exit(1);
+ }),
});
} else {
}