forked from lcampos/circleci-to-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli-setup.js
43 lines (35 loc) · 1.04 KB
/
cli-setup.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
const { info, error } = require('./utils/log');
const fs = require('fs');
const setup = options => {
try {
if (!options.token) {
throw new Error('--token is required');
}
const vcsType = options.vcs_type || 'github';
if (!options.vcs_type) {
info('Defaulting version control system setting to github');
}
if (!options.username) {
throw new Error('--username is required');
}
if (!options.project) {
throw new Error('--project is required');
}
if (!options.publisher) {
throw new Error('--publisher is required');
}
const inputConfig = {
CIRCLE_TOKEN: options.token,
vcs_type: vcsType,
username: options.username,
project: options.project,
vscode_publisher: options.publisher
};
fs.writeFileSync('./config.json', JSON.stringify(inputConfig, null, 2));
} catch (e) {
error(`Error while creating the cli configuration : ${e.message}`);
process.exit(1);
}
info('The cli was successfully configured.');
};
module.exports = { setup };