From 2dafc6bfb1af239f42d9b89c584b8d873573502a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Tue, 17 Oct 2023 10:25:53 +0200 Subject: [PATCH] fix: report error if dependency installation fails JST-498 --- src/new/new.action.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/new/new.action.ts b/src/new/new.action.ts index 96613ab..2be5181 100644 --- a/src/new/new.action.ts +++ b/src/new/new.action.ts @@ -137,15 +137,16 @@ function installDependencies(options: NewOptions, projectPath: string) { console.log("Installing dependencies..."); const pkg = getPackageManager(); - const oldWd = process.cwd(); const args = pkg.name === "yarn" ? [] : ["install"]; - process.chdir(projectPath); - const result = spawnSync(pkg.name, args, { stdio: "inherit" }); - process.chdir(oldWd); + const result = spawnSync(pkg.name, args, { cwd: projectPath, stdio: "inherit" }); if (result.error) { - console.error("Error: There was a problem installing dependencies. You may need to install them manually."); + console.error(`Error: There was a problem installing dependencies: ${result.error.message}`); + console.error("Note: You may need to install dependencies manually."); + } else if (result.status !== 0) { + console.error(`Error: Process existed with status code ${result.status}.`); + console.error("Note: You may need to install dependencies manually."); } }