Install packages separately
This commit is contained in:
parent
199e533059
commit
24ef426fbb
2 changed files with 31 additions and 16 deletions
|
@ -312,7 +312,7 @@ namespace ts.server {
|
||||||
// - newProgram is different from the old program and structure of the old program was not reused.
|
// - newProgram is different from the old program and structure of the old program was not reused.
|
||||||
if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) {
|
if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) {
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
this.projectService.typingsCache.invalidateCachedTypingsForProject(this);
|
//this.projectService.typingsCache.invalidateCachedTypingsForProject(this);
|
||||||
if (oldProgram) {
|
if (oldProgram) {
|
||||||
for (const f of oldProgram.getSourceFiles()) {
|
for (const f of oldProgram.getSourceFiles()) {
|
||||||
if (this.program.getSourceFileByPath(f.path)) {
|
if (this.program.getSourceFileByPath(f.path)) {
|
||||||
|
@ -405,16 +405,25 @@ namespace ts.server {
|
||||||
|
|
||||||
const added: string[] = [];
|
const added: string[] = [];
|
||||||
const removed: string[] = [];
|
const removed: string[] = [];
|
||||||
|
let invalidateTypings = false;
|
||||||
for (const id in currentFiles) {
|
for (const id in currentFiles) {
|
||||||
if (hasProperty(currentFiles, id) && !hasProperty(lastReportedFileNames, id)) {
|
if (hasProperty(currentFiles, id) && !hasProperty(lastReportedFileNames, id)) {
|
||||||
added.push(id);
|
added.push(id);
|
||||||
|
if (this.typingFiles.indexOf(id) < 0) {
|
||||||
|
invalidateTypings = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const id in lastReportedFileNames) {
|
for (const id in lastReportedFileNames) {
|
||||||
if (hasProperty(lastReportedFileNames, id) && !hasProperty(currentFiles, id)) {
|
if (hasProperty(lastReportedFileNames, id) && !hasProperty(currentFiles, id)) {
|
||||||
removed.push(id);
|
removed.push(id);
|
||||||
|
invalidateTypings = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (invalidateTypings) {
|
||||||
|
this.projectService.typingsCache.invalidateCachedTypingsForProject(this);
|
||||||
|
}
|
||||||
this.lastReportedFileNames = currentFiles;
|
this.lastReportedFileNames = currentFiles;
|
||||||
|
|
||||||
this.lastReportedFileNames = currentFiles;
|
this.lastReportedFileNames = currentFiles;
|
||||||
|
|
|
@ -114,23 +114,29 @@ namespace ts.server.typingsInstaller {
|
||||||
protected runInstall(cachePath: string, typingsToInstall: string[], postInstallAction: (installedTypings: string[]) => void): void {
|
protected runInstall(cachePath: string, typingsToInstall: string[], postInstallAction: (installedTypings: string[]) => void): void {
|
||||||
const id = this.installRunCount;
|
const id = this.installRunCount;
|
||||||
this.installRunCount++;
|
this.installRunCount++;
|
||||||
const command = `npm install ${typingsToInstall.map(t => "@types/" + t).join(" ")} --save-dev`;
|
let installCount = 0;
|
||||||
if (this.log.isEnabled()) {
|
const installedTypings: string[] = [];
|
||||||
this.log.writeLine(`Running npm install @types ${id}, command '${command}'. cache path '${cachePath}'`);
|
const expr = /^.*(@types\/\w+)\S*\s*$/gm;
|
||||||
}
|
let match: RegExpExecArray;
|
||||||
this.exec(command, { cwd: cachePath }, (err, stdout, stderr) => {
|
for (const typing of typingsToInstall) {
|
||||||
|
const command = `npm install @types/${typing} --save-dev`;
|
||||||
if (this.log.isEnabled()) {
|
if (this.log.isEnabled()) {
|
||||||
this.log.writeLine(`npm install @types ${id} stdout: ${stdout}`);
|
this.log.writeLine(`Running npm install @types ${id}, command '${command}'. cache path '${cachePath}'`);
|
||||||
this.log.writeLine(`npm install @types ${id} stderr: ${stderr}`);
|
|
||||||
}
|
}
|
||||||
const installedTypings: string[] = [];
|
this.exec(command, { cwd: cachePath }, (err, stdout, stderr) => {
|
||||||
const expr = /^.*(node_modules)\\(@types)\\(\S+)\s*$/gm;
|
installCount++;
|
||||||
let match: RegExpExecArray;
|
if (this.log.isEnabled()) {
|
||||||
while (match = expr.exec(stdout)) {
|
this.log.writeLine(`npm install @types ${id} stdout: ${stdout}`);
|
||||||
installedTypings.push(`${match[1]}/${match[2]}/${match[3]}`);
|
this.log.writeLine(`npm install @types ${id} stderr: ${stderr}`);
|
||||||
}
|
}
|
||||||
postInstallAction(installedTypings);
|
while (match = expr.exec(stdout)) {
|
||||||
});
|
installedTypings.push(`node_modules/${match[1]}`);
|
||||||
|
}
|
||||||
|
if (installCount >= typingsToInstall.length) {
|
||||||
|
postInstallAction(installedTypings);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue