build(broccoli-typescript): refactor output removal

this is just to make the code a bit more easier to follow
This commit is contained in:
Igor Minar 2015-05-20 11:28:39 -07:00
parent 2d6c44b54a
commit 4210b0e66a
1 changed files with 14 additions and 8 deletions

View File

@ -68,14 +68,7 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
this.rootFilePaths.splice(this.rootFilePaths.indexOf(tsFilePath), 1); this.rootFilePaths.splice(this.rootFilePaths.indexOf(tsFilePath), 1);
this.fileRegistry[tsFilePath] = null; this.fileRegistry[tsFilePath] = null;
this.removeOutputFor(tsFilePath);
let jsFilePath = tsFilePath.replace(/\.ts$/, '.js');
let mapFilePath = tsFilePath.replace(/.ts$/, '.js.map');
let dtsFilePath = tsFilePath.replace(/\.ts$/, '.d.ts');
fs.unlinkSync(path.join(this.cachePath, jsFilePath));
fs.unlinkSync(path.join(this.cachePath, mapFilePath));
fs.unlinkSync(path.join(this.cachePath, dtsFilePath));
}); });
if (this.firstRun) { if (this.firstRun) {
@ -155,6 +148,19 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
} }
} }
} }
private removeOutputFor(tsFilePath: string) {
let absoluteJsFilePath = path.join(this.cachePath, tsFilePath.replace(/\.ts$/, '.js'));
let absoluteMapFilePath = path.join(this.cachePath, tsFilePath.replace(/.ts$/, '.js.map'));
let absoluteDtsFilePath = path.join(this.cachePath, tsFilePath.replace(/\.ts$/, '.d.ts'));
if (fs.existsSync(absoluteJsFilePath)) {
fs.unlinkSync(absoluteJsFilePath);
fs.unlinkSync(absoluteMapFilePath);
fs.unlinkSync(absoluteDtsFilePath);
}
}
} }