Skip to content

Commit

Permalink
Merge pull request #156 from brendenpalmer/bpalmer/content-limit-simple
Browse files Browse the repository at this point in the history
invalidate `_content` on rebuild if necessary
  • Loading branch information
rwjblue committed Apr 14, 2021
2 parents 2727bb2 + 5435f8d commit 7de90f1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/strategies/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ class Entry {
}

set content(value) {
// if value is less than content limit, set it; otherwise invalidate
// previous content so we don't unexpectedly read from it later and
// get the old content
if (value.length < this._contentLimit) {
this._content = value;
} else {
this._content = undefined;
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions test/simple-concat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,32 @@ describe('simple-concat', function() {

await builder.build();
});

it('properly invalidates if contentLimit is exceeded on rebuild', async function() {
let node = concat(inputDir, {
outputFile: '/rebuild.js',
inputFiles: ['**/*.js'],
allowNone: true,
contentLimit: 5,
sourceMapConfig: { enabled: false }
});

builder = new broccoli.Builder(node);

await builder.build();
expect(read(builder.outputPath + '/rebuild.js')).to.eql('');

write('z.js', 'z');
write('a.js', 'a');
await builder.build();
expect(read(builder.outputPath + '/rebuild.js')).to.eql('a\nz');

write('a.js', 'abcdefg');
await builder.build();
expect(read(builder.outputPath + '/rebuild.js')).to.eql('abcdefg\nz');

await builder.build();
});
});

describe('CONCAT_STATS', function() {
Expand Down

0 comments on commit 7de90f1

Please sign in to comment.