UNPKG

703 BJavaScriptView Raw
1const Promise = require('bluebird');
2const semver = require('semver');
3const {headMessage, headBranch, headClean} = require('./core/git');
4
5const VALIDATE = 'validate';
6const UPGRADE = 'bump-dependencies';
7const BUMP = 'auto-bump';
8const SETUP = 'setup';
9const DIRTY = 'warn-dirty';
10const NOOP = 'noop';
11
12const selectCommand = async () => {
13 const [branch, message, clean] = await Promise.all([headBranch(), headMessage(), headClean()]);
14 if (!clean) return DIRTY;
15 if (branch !== 'master') return UPGRADE;
16 // §todo: make it configurable
17 if (semver.valid(message)) return UPGRADE;
18 return BUMP;
19};
20
21module.exports = {
22 UPGRADE,
23 BUMP,
24 DIRTY,
25 VALIDATE,
26 SETUP,
27 NOOP,
28 selectCommand
29};