UNPKG

@auto-canary/omit-commits

Version:

Omit commits plugin for auto

35 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** Ensure a value is an array */ const arrayify = (arr) => (Array.isArray(arr) ? arr : [arr]); /** Filter certain commits out of the changelog and version calculation. */ class OmitCommitsPlugin { /** Initialize the plugin with it's options */ constructor(options) { /** The name of the plugin */ this.name = 'Omit Commits'; this.options = { username: options.username ? arrayify(options.username) : [], email: options.email ? arrayify(options.email) : [], name: options.name ? arrayify(options.name) : [], subject: options.subject ? arrayify(options.subject) : [], labels: options.labels ? arrayify(options.labels) : [] }; } /** Tap into auto plugin points. */ apply(auto) { auto.hooks.onCreateLogParse.tap(this.name, logParse => { logParse.hooks.omitCommit.tap(this.name, commit => { if (commit.authors.find(author => Boolean(author.name && this.options.name.includes(author.name))) || commit.authors.find(author => Boolean(author.email && this.options.email.includes(author.email))) || commit.authors.find(author => Boolean(author.username && this.options.username.includes(author.username))) || commit.labels.find(label => Boolean(this.options.labels.includes(label))) || this.options.subject.find(str => commit.subject.includes(str))) { return true; } }); }); } } exports.default = OmitCommitsPlugin; //# sourceMappingURL=index.js.map