Compare View
Commits (2)
Changes
Showing 2 changed files Side-by-side Diff
package.json
rc-from-msg.js
1 | 1 | "use strict"; |
2 | 2 | |
3 | +function logOnDebug(msg) { | |
4 | + if (process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG) { | |
5 | + console.log(msg); | |
6 | + } | |
7 | +} | |
8 | + | |
3 | 9 | function run(msg, rules) { |
4 | 10 | if (typeof msg !== 'string') return; |
5 | 11 | if (!rules) return; |
... | ... | @@ -9,8 +15,10 @@ function run(msg, rules) { |
9 | 15 | for(let i = 0; i < rules_count; i++) { |
10 | 16 | const rule = rules[i]; |
11 | 17 | |
18 | + logOnDebug('RC-FROM-MSG: checking with rule: ' + JSON.stringify(rule)); | |
12 | 19 | const re = (typeof rule.flags === 'string') ? new RegExp(rule.pattern, rule.flags) : new RegExp(rule.pattern); |
13 | 20 | if (msg.search(re) > 0) { |
21 | + logOnDebug('RC-FROM-MSG: match with rule: ' + JSON.stringify(rule)); | |
14 | 22 | return rule.rc || rule.result; |
15 | 23 | } |
16 | 24 | } |