switch to using npm ls -json instead npm install -json

This commit is contained in:
Jason Ramsay 2016-09-01 12:30:32 -07:00
parent 3a993c89f3
commit 4f7a5185f8

View file

@ -109,7 +109,7 @@ namespace ts.server.typingsInstaller {
filteredTypings.push(typing); filteredTypings.push(typing);
} }
if (execInstallCmdCount >= typingsToInstall.length) { 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()) { if (this.log.isEnabled()) {
this.log.writeLine(`Running npm install @types ${id}, command '${command}'. cache path '${cachePath}'`); 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} stdout: ${stdout}`);
this.log.writeLine(`npm install @types ${id} stderr: ${stderr}`); this.log.writeLine(`npm install @types ${id} stderr: ${stderr}`);
} }
const installedTypings: string[] = []; if (stdout === "") {
try { return;
const response = JSON.parse(stdout); }
if (response.dependencies) { const command = "npm ls -json";
for (const typing in response.dependencies) { this.exec(command, { cwd: cachePath }, (err, stdout, stderr) => {
installedTypings.push(typing); 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) {
catch (e) { this.log.writeLine(`Error parsing installed @types dependencies. Error details: ${e.message}`);
this.log.writeLine(`Error parsing installed @types dependencies. Error details: ${e.message}`); }
} postInstallAction(installedTypings);
postInstallAction(installedTypings); });
}); });
} }
}); });