build(broccoli): improve error messaging from TreeDiffer

This commit is contained in:
Igor Minar
2015-05-27 18:26:28 -07:00
parent 9b0fa0dedc
commit 160c38b5ca
2 changed files with 14 additions and 1 deletions

View File

@ -31,7 +31,9 @@ export class TreeDiffer {
this.exclude = (excludeExtensions || []).length ? buildRegexp(excludeExtensions) : null;
function combine(prev, curr) {
if (curr.charAt(0) !== ".") throw new TypeError("Extension must begin with '.'");
if (curr.charAt(0) !== ".") {
throw new Error(`Extension must begin with '.'. Was: '${curr}'`);
}
let kSpecialRegexpChars = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;
curr = '(' + curr.replace(kSpecialRegexpChars, '\\$&') + ')';
return prev ? (prev + '|' + curr) : curr;