Skip to content

Commit 61972f4

Browse files
committed
fixed bugs in RuleSet, added tests
1 parent 78a2f69 commit 61972f4

File tree

5 files changed

+296
-275
lines changed

5 files changed

+296
-275
lines changed

lib/RuleSet.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ RuleSet.normalizeRule = function(rule) {
132132
if(typeof loader === "string" && !rule.options && !rule.query) {
133133
checkUseSource("loader");
134134
newRule.use = RuleSet.normalizeUse(loader.split("!"));
135-
} else if(typeof loader === "string" || rule.options || rule.query) {
135+
} else if(typeof loader === "string" && (rule.options || rule.query)) {
136136
checkUseSource("loader + options/query");
137137
newRule.use = RuleSet.normalizeUse({
138138
loader: loader,
139139
options: rule.options,
140140
query: rule.query
141141
});
142+
} else if(loader && (rule.options || rule.query)) {
143+
throw new Error("options/query cannot be used with loaders");
142144
} else if(loader) {
143145
checkUseSource("loaders");
144146
newRule.use = RuleSet.normalizeUse(loader);
@@ -208,6 +210,9 @@ RuleSet.normalizeUseItem = function normalizeUseItem(item) {
208210
if(item.options && item.query)
209211
throw new Error("Provided options and query in use");
210212

213+
if(!item.loader)
214+
throw new Error("No loader specified");
215+
211216
newItem.options = item.options || item.query;
212217

213218
var keys = Object.keys(item).filter(function(key) {
@@ -288,7 +293,7 @@ function notMatcher(matcher) {
288293
function orMatcher(items) {
289294
return function(str) {
290295
for(var i = 0; i < items.length; i++) {
291-
if(items(str))
296+
if(items[i](str))
292297
return true;
293298
}
294299
return false;
@@ -298,7 +303,7 @@ function orMatcher(items) {
298303
function andMatcher(items) {
299304
return function(str) {
300305
for(var i = 0; i < items.length; i++) {
301-
if(!items(str))
306+
if(!items[i](str))
302307
return false;
303308
}
304309
return true;

test/LoaderList.test.js

Lines changed: 0 additions & 269 deletions
This file was deleted.

0 commit comments

Comments
 (0)