@@ -56,7 +56,7 @@ export function resolveRelative(loc: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export function list(val: string): Array<string> {
|
||||
export function list(val: string): Array {
|
||||
if (!val) {
|
||||
return [];
|
||||
} else if (Array.isArray(val)) {
|
||||
@@ -114,18 +114,26 @@ export function shouldIgnore(filename, ignore, only) {
|
||||
|
||||
if (only) {
|
||||
for (let pattern of (only: Array)) {
|
||||
if (pattern.test(filename)) return false;
|
||||
if (_shouldIgnore(pattern, filename)) return false;
|
||||
}
|
||||
return true;
|
||||
} else if (ignore.length) {
|
||||
for (let pattern of (ignore: Array)) {
|
||||
if (pattern.test(filename)) return true;
|
||||
if (_shouldIgnore(pattern, filename)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _shouldIgnore(pattern, filename) {
|
||||
if (typeof pattern === "function") {
|
||||
return pattern(filename);
|
||||
} else {
|
||||
return pattern.test(filename);
|
||||
}
|
||||
}
|
||||
|
||||
var templateVisitor = {
|
||||
noScope: true,
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ suite("util", function () {
|
||||
assert.deepEqual(util.arrayify("foo,bar"), ["foo", "bar"]);
|
||||
assert.deepEqual(util.arrayify(["foo", "bar"]), ["foo", "bar"]);
|
||||
assert.deepEqual(util.arrayify({ foo: "bar" }), [{ foo: "bar" }]);
|
||||
assert.deepEqual(util.arrayify(function () { return "foo"; })[0](), "foo");
|
||||
});
|
||||
|
||||
test("regexify", function () {
|
||||
@@ -110,4 +111,20 @@ suite("util", function () {
|
||||
assert.equal(t.toIdentifier(t.identifier("swag")), "swag");
|
||||
assert.equal(t.toIdentifier("swag-lord"), "swagLord");
|
||||
});
|
||||
|
||||
test("shouldIgnore", function () {
|
||||
var reIgnore = /\-reIgnore\.js/;
|
||||
var fnIgnore = function (src) {
|
||||
if (src.indexOf("fnIgnore") > 0) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
assert.equal(util.shouldIgnore("test.js", []), false);
|
||||
assert.equal(util.shouldIgnore("test-reIgnore.js", [fnIgnore]), false);
|
||||
assert.equal(util.shouldIgnore("test-reIgnore.js", [reIgnore]), true);
|
||||
|
||||
assert.equal(util.shouldIgnore("test-fnIgnore.js", [fnIgnore]), true);
|
||||
assert.equal(util.shouldIgnore("test-fnIgnore.js", [reIgnore]), false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user