Skip to content

Commit d309df1

Browse files
authored
fix: properly log error when dependency install fails (#228)
* log error when installs fail * changeset
1 parent 2d33dbb commit d309df1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.changeset/yellow-sheep-guess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
fix: log error when dependency installs fail

packages/cli/commands/add/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ async function runAdders({
545545
if (workspace.packageManager === 'npm') args.unshift('--yes');
546546

547547
try {
548-
await exec(command, args, { nodeOptions: { cwd: workspace.cwd, stdio: script.stdio } });
548+
const { stderr } = await exec(command, args, {
549+
nodeOptions: { cwd: workspace.cwd, stdio: script.stdio }
550+
});
551+
if (stderr) throw new Error(stderr);
549552
} catch (error) {
550553
const typedError = error as Error;
551554
throw new Error(

packages/cli/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export async function installDependencies(agent: AgentName, cwd: string) {
7676
spinner.start('Installing dependencies...');
7777
try {
7878
const { command, args } = constructCommand(COMMANDS[agent].install, [])!;
79-
await exec(command, args, { nodeOptions: { cwd } });
79+
const { stderr } = await exec(command, args, { nodeOptions: { cwd } });
80+
if (stderr) throw new Error(stderr);
81+
8082
spinner.stop('Successfully installed dependencies');
8183
} catch (error) {
8284
spinner.stop('Failed to install dependencies', 2);

0 commit comments

Comments
 (0)