Skip to content

Commit

Permalink
Merge pull request #147 from broccolijs/ensure-additional-trees-dont-…
Browse files Browse the repository at this point in the history
…leak
  • Loading branch information
rwjblue authored Jun 17, 2021
2 parents 1ec8bc2 + cfc238e commit dcae5e2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class Funnel extends Plugin {
}
}

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

let linkedRoots = false;
if (this.shouldLinkRoots()) {
Expand Down Expand Up @@ -317,9 +317,9 @@ class Funnel extends Plugin {
} else {

if (this._matchedWalk) {
entries = this.input.entries(this.srcDir || './', { globs: this.include, ignore: this.exclude });
entries = this.input.at(0).entries(this.srcDir || './', { globs: this.include, ignore: this.exclude });
} else {
entries = this.input.entries(this.srcDir || './');
entries = this.input.at(0).entries(this.srcDir || './');
}

entries = this._processEntries(entries);
Expand Down
34 changes: 34 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,5 +1167,39 @@ describe('broccoli-funnel', function() {

expect(walkSync(outputPath)).to.eql(['lol/', 'lol/foo.js']);
});

it('providing additional trees does not change matched files', async function() {
class FunnelSubclass extends Funnel.Funnel {
constructor(inputNode, options) {
super([inputNode, input.path('dir1/subdir1/subsubdir2')], options);

this._hasBuilt = false;
}

build() {
if (this._hasBuilt === false) {
if (!fs.existsSync(`${this.inputPaths[1]}/some.js`)) {
throw new Error('Could not find file!!!');
}
// set custom destDir to ensure our custom build code ran
this.destDir = 'lol';
this._hasBuilt = true;
}

return super.build();
}
}

let inputPath = input.path('lib/utils');
let node = new FunnelSubclass(inputPath, {
include: ['**/*.js'],
});
output = createBuilder(node);

await output.build();
let outputPath = output.path();

expect(walkSync(outputPath)).to.eql(['lol/', 'lol/foo.js']);
});
});
});

0 comments on commit dcae5e2

Please sign in to comment.