-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
59 lines (52 loc) · 1.45 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @file index.js
*
* Copyright (c) 2020 Simon Fraser University
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
*
* @brief Entry point to the command line tool
*
* It parses the arguments passed to the command line tool and decides which module to invoke
*/
const minimist = require('minimist')
const shell = require('shelljs')
const help = require('./src/help')
const version = require('./src/version')
const validateAllReleases = require('./src/validate-all-releases')
const validateNewRelease = require('./src/validate-new-release')
const bump = require('./src/bump')
const release = require('./src/release')
const { error } = require('./src/utils/log')
const start = async args => {
try {
const params = minimist(args)
let cmd = params._[0] || 'help'
if (params.version || params.v) {
cmd = 'version'
}
if (params.help || params.h) {
cmd = 'help'
}
switch (cmd) {
case 'release':
return release(params)
case 'bump':
return bump(params)
case 'validate-new-release':
return validateNewRelease(params)
case 'validate-all-releases':
return validateAllReleases(params)
case 'version':
return version(params)
case 'help':
return help(params)
default:
error(`"${cmd}" is not a valid command!`)
break
}
} catch (err) {
error(err)
shell.exit(1)
}
}
start(process.argv.slice(2))