Skip to content

Commit cfc238e

Browse files
author
Robert Jackson
committed
Ensure adding additional trees does not affect include/exclude results.
In a7ed4fa we added support for passing additional trees to the constructor (to ensure that they can be ready to read in subclasses), but we didn't ensure that all internal usage of `this.input` was limited to the first tree passed. This didn't matter much for the simple symlink srcDir <-> destDir situation, but as soon as you use custom `include`/`exclude` globs (and we therefore have to walk all the files) we would trigger errors. This fixes that oversight by ensuring that all usage of `this.input` is scoped to `this.input.at(0)`, and adds a previously failing test.
1 parent 1ec8bc2 commit cfc238e

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class Funnel extends Plugin {
192192
}
193193
}
194194

195-
let inputPathExists = this.input.existsSync(this.srcDir || './');
195+
let inputPathExists = this.input.at(0).fs.existsSync(this.srcDir || './');
196196

197197
let linkedRoots = false;
198198
if (this.shouldLinkRoots()) {
@@ -317,9 +317,9 @@ class Funnel extends Plugin {
317317
} else {
318318

319319
if (this._matchedWalk) {
320-
entries = this.input.entries(this.srcDir || './', { globs: this.include, ignore: this.exclude });
320+
entries = this.input.at(0).entries(this.srcDir || './', { globs: this.include, ignore: this.exclude });
321321
} else {
322-
entries = this.input.entries(this.srcDir || './');
322+
entries = this.input.at(0).entries(this.srcDir || './');
323323
}
324324

325325
entries = this._processEntries(entries);

tests/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,5 +1167,39 @@ describe('broccoli-funnel', function() {
11671167

11681168
expect(walkSync(outputPath)).to.eql(['lol/', 'lol/foo.js']);
11691169
});
1170+
1171+
it('providing additional trees does not change matched files', async function() {
1172+
class FunnelSubclass extends Funnel.Funnel {
1173+
constructor(inputNode, options) {
1174+
super([inputNode, input.path('dir1/subdir1/subsubdir2')], options);
1175+
1176+
this._hasBuilt = false;
1177+
}
1178+
1179+
build() {
1180+
if (this._hasBuilt === false) {
1181+
if (!fs.existsSync(`${this.inputPaths[1]}/some.js`)) {
1182+
throw new Error('Could not find file!!!');
1183+
}
1184+
// set custom destDir to ensure our custom build code ran
1185+
this.destDir = 'lol';
1186+
this._hasBuilt = true;
1187+
}
1188+
1189+
return super.build();
1190+
}
1191+
}
1192+
1193+
let inputPath = input.path('lib/utils');
1194+
let node = new FunnelSubclass(inputPath, {
1195+
include: ['**/*.js'],
1196+
});
1197+
output = createBuilder(node);
1198+
1199+
await output.build();
1200+
let outputPath = output.path();
1201+
1202+
expect(walkSync(outputPath)).to.eql(['lol/', 'lol/foo.js']);
1203+
});
11701204
});
11711205
});

0 commit comments

Comments
 (0)