Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/broccoli/broccoli-dartfmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DartFormatter implements DiffingBroccoliPlugin {

rebuild(treeDiff: DiffResult): Promise<any> {
let args = ['-w'];
treeDiff.changedPaths.forEach((changedFile) => {
treeDiff.addedPaths.concat(treeDiff.changedPaths).forEach((changedFile) => {
let sourcePath = path.join(this.inputPath, changedFile);
let destPath = path.join(this.cachePath, changedFile);
if (/\.dart$/.test(changedFile)) args.push(destPath);
Expand Down
2 changes: 1 addition & 1 deletion tools/broccoli/broccoli-dest-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DestCopy implements DiffingBroccoliPlugin {


rebuild(treeDiff: DiffResult) {
treeDiff.changedPaths.forEach((changedFilePath) => {
treeDiff.addedPaths.concat(treeDiff.changedPaths).forEach((changedFilePath) => {
var destFilePath = path.join(this.outputRoot, changedFilePath);

var destDirPath = path.dirname(destFilePath);
Expand Down
77 changes: 77 additions & 0 deletions tools/broccoli/broccoli-funnel.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/// <reference path="../typings/node/node.d.ts" />
/// <reference path="../typings/jasmine/jasmine.d.ts" />

let mockfs = require('mock-fs');
import fs = require('fs');
import path = require('path');
import {TreeDiffer} from './tree-differ';
import {DiffingFunnel} from './broccoli-funnel';


//describe('DiffingFunnel', () => {
// afterEach(() => mockfs.restore());
//
//
// it('should pick all files under the root', () => {
// let testDir = {
// 'inputTree': {
// 'dir1': {
// 'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
// 'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}),
// 'subdir-1': {
// 'file-1.1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
// },
// 'empty-dir': {}
// }
// },
// 'outputTree': {}
// };
// mockfs(testDir);
//
// let funnelTree = funnel('dir1');
// let treeDiffer = new TreeDiffer('test label', 'dir1');
// funnelTree.rebuild(treeDiffer.diffTree());
// //funnelTree.rebuild({
// // changedPaths: ['file-1.txt', 'file-2.txt', 'subdir-1/file-1.1.txt'],
// // removedPaths: []
// //});
//
// expectOutputToBe(['dir1/file-1.txt', 'dir1/file-2.txt', 'dir1/subdir-1/file-1.1.txt']);
//
// delete testDir.inputTree.dir1['file-1.txt'];
// mockfs(testDir);
// funnelTree.rebuild(treeDiffer.diffTree());
// expectOutputToBe(['dir1/file-2.txt', 'dir1/subdir-1/file-1.1.txt']);
//
// testDir.inputTree.dir1['subdir-1']['file-1.2.txt'] =
// mockfs.file({content: 'file-1.2.txt content', mtime: new Date(1000)});
// mockfs(testDir);
//
// funnelTree.rebuild(treeDiffer.diffTree());
// expectOutputToBe(['dir1/file-2.txt', 'dir1/subdir-1/file-1.1.txt',
// 'dir1/subdir-1/file-1.2.txt']);
// });
//
//
//
// function funnel(rootDir) {
// return new DiffingFunnel('inputTree', 'outputTree', [rootDir]);
// }
//
// function expectOutputToBe(paths) {
// paths.forEach(path => {
// expect(fs.readdirSync('outputTree/' + path)).toBe('inputTree/' + path);
// });
// }
//
// function extractPaths(object) {
// let files = [];
//
// Object.keys(object).forEach(segment => {
// let segmentType = typeof object[segment].getContent;
// if (segmentType === 'function' || segmentType === 'string') {
// files.push(segment);
// }
// })
// }
//});
25 changes: 25 additions & 0 deletions tools/broccoli/broccoli-funnel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// <reference path="../typings/node/node.d.ts" />
/// <reference path="../typings/fs-extra/fs-extra.d.ts" />

import fs = require('fs');
import fse = require('fs-extra');
import path = require('path');
import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';

export class DiffingFunnel implements DiffingBroccoliPlugin {

constructor(public inputPath: string, public cachePath: string, public options) {}

rebuild(treeDiff: DiffResult) {

treeDiff.addedPaths.forEach(changedPath => {
fs.linkSync(path.join(this.inputPath, changedPath), path.join(this.cachePath, changedPath));
});

treeDiff.removedPaths.forEach(removedPath => {
fs.unlinkSync(path.join(this.cachePath, removedPath));
});
}
}

export default wrapDiffingPlugin(DiffingFunnel);
3 changes: 1 addition & 2 deletions tools/broccoli/broccoli-ts2dart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="./broccoli-writer.d.ts" />
/// <reference path="../typings/node/node.d.ts" />
/// <reference path="../typings/fs-extra/fs-extra.d.ts" />
/// <reference path="./ts2dart.d.ts" />
Expand All @@ -23,7 +22,7 @@ class TSToDartTranspiler implements DiffingBroccoliPlugin {
rebuild(treeDiff: DiffResult) {
let toEmit = [];
let getDartFilePath = (path: string) => path.replace(/((\.js)|(\.ts))$/i, '.dart');
treeDiff.changedPaths.forEach((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
Expand Down
2 changes: 1 addition & 1 deletion tools/broccoli/broccoli-typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
let pathsToEmit = [];
let pathsWithErrors = [];

treeDiff.changedPaths
treeDiff.addedPaths.concat(treeDiff.changedPaths)
.forEach((tsFilePath) => {
if (!this.fileRegistry[tsFilePath]) {
this.fileRegistry[tsFilePath] = {version: 0};
Expand Down
18 changes: 12 additions & 6 deletions tools/broccoli/diffing-broccoli-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,19 @@ class DiffingPluginWrapper implements BroccoliTree {

private init() {
if (!this.initialized) {
let includeExtensions = this.pluginClass.includeExtensions || [];
let excludeExtensions = this.pluginClass.excludeExtensions || [];
this.initialized = true;
this.treeDiffer =
new TreeDiffer(this.description, this.inputPath, includeExtensions, excludeExtensions);
this.wrappedPlugin =
new this.pluginClass(this.inputPath, this.cachePath, this.wrappedPluginArguments[1]);

let pluginOptions = this.wrappedPluginArguments[1];
let filteringOptions = {
includeExtensions: this.pluginClass.includeExtensions,
excludeExtensions: this.pluginClass.excludeExtensions,
include: pluginOptions.include,
exclude: pluginOptions.exclude,
files: pluginOptions.files
};

this.treeDiffer = new TreeDiffer(this.description, this.inputPath, filteringOptions);
this.wrappedPlugin = new this.pluginClass(this.inputPath, this.cachePath, pluginOptions);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/broccoli/traceur/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DiffingTraceurCompiler implements DiffingBroccoliPlugin {
static includeExtensions = ['.js', '.es6', '.cjs'];

rebuild(treeDiff: DiffResult) {
treeDiff.changedPaths.forEach((changedFilePath) => {
treeDiff.addedPaths.concat(treeDiff.changedPaths).forEach((changedFilePath) => {
var traceurOpts = xtend({filename: changedFilePath}, this.options.traceurOptions);

var fsOpts = {encoding: 'utf-8'};
Expand Down
Loading