build(broccoli): add support for DiffResult#addedPaths

Some plugins want to explicitly know of new paths, so we need to distinguish them from changed paths.
This commit is contained in:
Igor Minar
2015-05-31 17:24:21 -07:00
parent efab03274f
commit dc45559c17
13 changed files with 204 additions and 106 deletions

View File

@ -23,16 +23,17 @@ class TSToDartTranspiler implements DiffingBroccoliPlugin {
rebuild(treeDiff: DiffResult) {
let toEmit = [];
let getDartFilePath = (path: string) => path.replace(/((\.js)|(\.ts))$/i, '.dart');
treeDiff.changedPaths.forEach((changedPath) => {
let inputFilePath = path.resolve(this.inputPath, changedPath);
treeDiff.addedPaths.concat(treeDiff.changedPaths)
.forEach((changedPath) => {
let inputFilePath = path.resolve(this.inputPath, changedPath);
// Ignore files which don't need to be transpiled to Dart
let dartInputFilePath = getDartFilePath(inputFilePath);
if (fs.existsSync(dartInputFilePath)) return;
// Ignore files which don't need to be transpiled to Dart
let dartInputFilePath = getDartFilePath(inputFilePath);
if (fs.existsSync(dartInputFilePath)) return;
// Prepare to rebuild
toEmit.push(path.resolve(this.inputPath, changedPath));
});
// Prepare to rebuild
toEmit.push(path.resolve(this.inputPath, changedPath));
});
treeDiff.removedPaths.forEach((removedPath) => {
let absolutePath = path.resolve(this.inputPath, removedPath);