diff --git a/.changeset/fix-cli-await-post-install.md b/.changeset/fix-cli-await-post-install.md new file mode 100644 index 00000000000..2b8f15f5f6a --- /dev/null +++ b/.changeset/fix-cli-await-post-install.md @@ -0,0 +1,5 @@ +--- +'@qwik.dev/core': patch +--- + +fix(cli): wait for an integration's `postInstall` script to finish before `qwik add` exits, and report when it fails diff --git a/packages/qwik/src/cli/add/run-add-interactive.ts b/packages/qwik/src/cli/add/run-add-interactive.ts index 087e8f24eca..38d5df03442 100644 --- a/packages/qwik/src/cli/add/run-add-interactive.ts +++ b/packages/qwik/src/cli/add/run-add-interactive.ts @@ -1,5 +1,5 @@ import { intro, isCancel, log, outro, select, spinner } from '@clack/prompts'; -import { bgBlue, bgMagenta, blue, bold, cyan, magenta } from 'kleur/colors'; +import { bgBlue, bgMagenta, blue, bold, cyan, magenta, red } from 'kleur/colors'; import type { IntegrationData, UpdateAppOptions, UpdateAppResult } from '../types'; import { loadIntegrations, sortIntegrationsAndReturnAsClackOptions } from '../utils/integrations'; import { bye, getPackageManager, note, panic } from '../utils/utils'; @@ -79,8 +79,18 @@ export async function runAddInteractive(app: AppCommand, id: string | undefined) if (postInstall) { const s = spinner(); s.start(`Running post install script: ${postInstall}`); - await runInPkg(pkgManager, postInstall.split(' '), app.rootDir); - s.stop('Post install script complete'); + const { install } = await runInPkg(pkgManager, postInstall.split(' '), app.rootDir); + if (await install) { + s.stop('Post install script complete'); + } else { + s.stop(red(`Post install script failed: ${postInstall}`)); + const runPrefix = pkgManager === 'npm' ? 'npx' : pkgManager; + note( + `The integration files were added, but its post install script failed.\nFix the error above, then run it again:\n ${runPrefix} ${postInstall}`, + 'Action Required!' + ); + process.exit(1); + } } logUpdateAppCommitResult(result, pkgManager);