diff --git a/lib/analyze-commit.js b/lib/analyze-commit.js index 35a4e7d1..77464f8e 100644 --- a/lib/analyze-commit.js +++ b/lib/analyze-commit.js @@ -1,10 +1,9 @@ -import { isMatchWith, isString } from "lodash-es"; -import micromatch from "micromatch"; -import debugFactory from "debug"; -import RELEASE_TYPES from "./default-release-types.js"; -import compareReleaseTypes from "./compare-release-types.js"; +import { isMatchWith, isString } from 'lodash-es' +import debugFactory from 'debug' +import RELEASE_TYPES from './default-release-types.js' +import compareReleaseTypes from './compare-release-types.js' -const debug = debugFactory("semantic-release:commit-analyzer"); +const debug = debugFactory('semantic-release:commit-analyzer') /** * Find all the rules matching and return the highest release type of the matching rules. * @@ -13,7 +12,7 @@ const debug = debugFactory("semantic-release:commit-analyzer"); * @return {string} the highest release type of the matching rules or `undefined` if no rule match the commit. */ export default (releaseRules, commit) => { - let releaseType; + let releaseType releaseRules .filter( @@ -23,29 +22,27 @@ export default (releaseRules, commit) => { // If the rule is not `revert` or the commit is not a revert (!revert || commit.revert) && // Otherwise match the regular rules - isMatchWith(commit, rule, (object, src) => - isString(src) && isString(object) ? micromatch.isMatch(object, src) : undefined - ) + isMatchWith(commit, rule, (object, src) => new RegExp(src).test(object)) ) .every((match) => { if (compareReleaseTypes(releaseType, match.release)) { - releaseType = match.release; - debug("The rule %o match commit with release type %o", match, releaseType); + releaseType = match.release + debug('The rule %o match commit with release type %o', match, releaseType) if (releaseType === RELEASE_TYPES[0]) { - debug("Release type %o is the highest possible. Stop analysis.", releaseType); - return false; + debug('Release type %o is the highest possible. Stop analysis.', releaseType) + return false } } else { debug( - "The rule %o match commit with release type %o but the higher release type %o has already been found for this commit", + 'The rule %o match commit with release type %o but the higher release type %o has already been found for this commit', match, match.release, releaseType - ); + ) } - return true; - }); + return true + }) - return releaseType; -}; + return releaseType +}