1 | const Promise = require('bluebird');
|
2 | const semver = require('semver');
|
3 | const {headMessage, headBranch, headClean} = require('./core/git');
|
4 |
|
5 | const VALIDATE = 'validate';
|
6 | const UPGRADE = 'bump-dependencies';
|
7 | const BUMP = 'auto-bump';
|
8 | const SETUP = 'setup';
|
9 | const DIRTY = 'warn-dirty';
|
10 | const NOOP = 'noop';
|
11 |
|
12 | const 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 |
|
17 | if (semver.valid(message)) return UPGRADE;
|
18 | return BUMP;
|
19 | };
|
20 |
|
21 | module.exports = {
|
22 | UPGRADE,
|
23 | BUMP,
|
24 | DIRTY,
|
25 | VALIDATE,
|
26 | SETUP,
|
27 | NOOP,
|
28 | selectCommand
|
29 | };
|