From 4f7a5185f8304cf136d176075ba0c62433b3c3c9 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Thu, 1 Sep 2016 12:30:32 -0700 Subject: [PATCH] switch to using npm ls -json instead npm install -json --- .../typingsInstaller/nodeTypingsInstaller.ts | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 3745b32029..d9dddfabc9 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -109,7 +109,7 @@ namespace ts.server.typingsInstaller { filteredTypings.push(typing); } if (execInstallCmdCount >= typingsToInstall.length) { - const command = `npm install ${filteredTypings.map(t => "@types/" + t).join(" ")} --save-dev -json`; + const command = `npm install ${filteredTypings.map(t => "@types/" + t).join(" ")} --save-dev`; if (this.log.isEnabled()) { this.log.writeLine(`Running npm install @types ${id}, command '${command}'. cache path '${cachePath}'`); } @@ -118,19 +118,29 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`npm install @types ${id} stdout: ${stdout}`); this.log.writeLine(`npm install @types ${id} stderr: ${stderr}`); } - const installedTypings: string[] = []; - try { - const response = JSON.parse(stdout); - if (response.dependencies) { - for (const typing in response.dependencies) { - installedTypings.push(typing); + if (stdout === "") { + return; + } + const command = "npm ls -json"; + this.exec(command, { cwd: cachePath }, (err, stdout, stderr) => { + if (this.log.isEnabled()) { + this.log.writeLine(`npm ls -json ${id} stdout: ${stdout}`); + this.log.writeLine(`npm ls -json ${id} stderr: ${stderr}`); + } + const installedTypings: string[] = []; + try { + const response = JSON.parse(stdout); + if (response.dependencies) { + for (const typing in response.dependencies) { + installedTypings.push(typing); + } } } - } - catch (e) { - this.log.writeLine(`Error parsing installed @types dependencies. Error details: ${e.message}`); - } - postInstallAction(installedTypings); + catch (e) { + this.log.writeLine(`Error parsing installed @types dependencies. Error details: ${e.message}`); + } + postInstallAction(installedTypings); + }); }); } });