From f8be834c22e061afee9160ce70f5f452eae23472 Mon Sep 17 00:00:00 2001 From: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com> Date: Mon, 2 Feb 2026 20:54:33 +0100 Subject: [PATCH] fix: use `spawn` --- utils/src/remove-dependencies.ts | 35 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/utils/src/remove-dependencies.ts b/utils/src/remove-dependencies.ts index 602b2747..6378d6e7 100644 --- a/utils/src/remove-dependencies.ts +++ b/utils/src/remove-dependencies.ts @@ -1,4 +1,4 @@ -import { execSync } from 'node:child_process'; +import { spawn } from 'node:child_process'; import { existsSync, readFileSync, writeFileSync } from 'node:fs'; /** @@ -91,24 +91,23 @@ function detectPackageManager(): 'npm' | 'yarn' | 'pnpm' { function runPackageManagerInstall( packageManager: 'npm' | 'yarn' | 'pnpm', ): void { - try { - console.log(`Running ${packageManager} install to update dependencies...`); - - switch (packageManager) { - case 'npm': - execSync('npm install', { stdio: 'inherit' }); - break; - case 'yarn': - execSync('yarn install', { stdio: 'inherit' }); - break; - case 'pnpm': - execSync('pnpm install', { stdio: 'inherit' }); - break; - } + console.log(`Running ${packageManager} install to update dependencies...`); - console.log(`Successfully updated dependencies with ${packageManager}`); - } catch (error) { + const command = packageManager; + const args = ['install']; + + const child = spawn(command, args, { stdio: 'inherit' }); + + child.on('error', (error) => { console.error(`Error running ${packageManager} install:`, error); // Don't throw - dependency removal was successful, install failure shouldn't break the codemod - } + }); + + child.on('close', (code) => { + if (code === 0) { + console.log(`Successfully updated dependencies with ${packageManager}`); + } else { + console.error(`${packageManager} install exited with code ${code}`); + } + }); }