Skip to content

Commit 160c38b

Browse files
committed
build(broccoli): improve error messaging from TreeDiffer
1 parent 9b0fa0d commit 160c38b

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

tools/broccoli/tree-differ.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ describe('TreeDiffer', () => {
177177
});
178178

179179

180+
it("should throw an error if an extension isn't prefixed with doc", () => {
181+
// includeExtensions
182+
expect(() => new TreeDiffer('testLabel', 'dir1', ['js']))
183+
.toThrowError("Extension must begin with '.'. Was: 'js'");
184+
185+
// excludeExtentions
186+
expect(() => new TreeDiffer('testLabel', 'dir1', [], ['js']))
187+
.toThrowError("Extension must begin with '.'. Was: 'js'");
188+
});
189+
190+
180191
it('should ignore files with extensions not listed in includeExtensions', () => {
181192
let testDir = {
182193
'dir1': {

tools/broccoli/tree-differ.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export class TreeDiffer {
3131
this.exclude = (excludeExtensions || []).length ? buildRegexp(excludeExtensions) : null;
3232

3333
function combine(prev, curr) {
34-
if (curr.charAt(0) !== ".") throw new TypeError("Extension must begin with '.'");
34+
if (curr.charAt(0) !== ".") {
35+
throw new Error(`Extension must begin with '.'. Was: '${curr}'`);
36+
}
3537
let kSpecialRegexpChars = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;
3638
curr = '(' + curr.replace(kSpecialRegexpChars, '\\$&') + ')';
3739
return prev ? (prev + '|' + curr) : curr;

0 commit comments

Comments
 (0)