From 268168175e489eb7d2b462d2cb5145227380898b Mon Sep 17 00:00:00 2001 From: Clunt Date: Tue, 29 May 2018 12:43:11 +0800 Subject: [PATCH] feat(Match): support strict option --- lib/Match.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Match.js b/lib/Match.js index 7d21602..af4c712 100644 --- a/lib/Match.js +++ b/lib/Match.js @@ -8,6 +8,7 @@ const VAR = require('./VAR'); function Match(option, rules) { this.option = option; + this.strict = option.strict; this.rules = []; this.init(rules); } @@ -100,9 +101,15 @@ Match.prototype.init = function (release) { }; Match.prototype.test = function (path) { + if (this.rules.length === 0) { + return this.strict ? VAR.TEST_STAT.UNRELEASE_UNMATCHED : VAR.TEST_STAT.RELEASE; + } + const matchMode = this.option.match; + let release = false; let matched = false; + this.rules.forEach(rule => { const stat = rule.test(path); switch (stat) {