Skip to content

Commit 24b7ef2

Browse files
committed
chore: extract into matchesWorkflow util
1 parent 0409c38 commit 24b7ef2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

addon/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ setupDeprecationWorkflow({
2626
let postamble = ` ]
2727
});`;
2828

29+
function matchesWorkflow(matcher, value) {
30+
return (
31+
(typeof matcher === 'string' && matcher === value) ||
32+
(matcher instanceof RegExp && matcher.exec(value))
33+
);
34+
}
35+
2936
export function detectWorkflow(config, message, options) {
3037
if (!config || !config.workflow) {
3138
return;
@@ -38,10 +45,8 @@ export function detectWorkflow(config, message, options) {
3845
idMatcher = workflow.matchId;
3946

4047
if (
41-
(typeof idMatcher === 'string' && options && idMatcher === options.id) ||
42-
(idMatcher instanceof RegExp && idMatcher.exec(options.id)) ||
43-
(typeof matcher === 'string' && matcher === message) ||
44-
(matcher instanceof RegExp && matcher.exec(message))
48+
matchesWorkflow(idMatcher, options?.id) ||
49+
matchesWorkflow(matcher, message)
4550
) {
4651
return workflow;
4752
}

0 commit comments

Comments
 (0)