-
Notifications
You must be signed in to change notification settings - Fork 48.4k
/
Copy pathparse-params.js
66 lines (59 loc) · 1.47 KB
/
parse-params.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
60
61
62
63
64
65
66
#!/usr/bin/env node
'use strict';
const commandLineArgs = require('command-line-args');
const theme = require('../theme');
const paramDefinitions = [
{
name: 'build',
type: String,
description:
'CI build ID corresponding to the "process_artifacts_combined" task.',
defaultValue: null,
},
{
name: 'commit',
type: String,
description:
'GitHub commit SHA. When provided, automatically finds corresponding CI build.',
defaultValue: null,
},
{
name: 'skipTests',
type: Boolean,
description: 'Skip automated fixture tests.',
defaultValue: false,
},
{
name: 'releaseChannel',
alias: 'r',
type: String,
description: 'Release channel (stable, experimental, or latest)',
},
{
name: 'allowBrokenCI',
type: Boolean,
description:
'Continue even if CI is failing. Useful if you need to debug a broken build.',
defaultValue: false,
},
];
module.exports = async () => {
const params = commandLineArgs(paramDefinitions);
const channel = params.releaseChannel;
if (
channel !== 'experimental' &&
channel !== 'stable' &&
channel !== 'rc' &&
channel !== 'latest'
) {
console.error(
theme.error`Invalid release channel (-r) "${channel}". Must be "stable", "experimental", "rc", or "latest".`
);
process.exit(1);
}
if (params.commit === null) {
console.error(theme.error`A --commit param must be specified.`);
process.exit(1);
}
return params;
};