Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/fix-cli-await-post-install.md
Original file line number Diff line number Diff line change
@@ -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
16 changes: 13 additions & 3 deletions packages/qwik/src/cli/add/run-add-interactive.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
logUpdateAppCommitResult(result, pkgManager);

Expand Down