-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcli-install-vsix.js
37 lines (31 loc) · 1021 Bytes
/
cli-install-vsix.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
const { extract, download, httpsGet } = require('./utils/reqmod');
const {
buildHTTPOpts,
getVsixName
} = require('./utils/circleci');
const { info, error } = require('./utils/log');
const { configExists, readConfigFile } = require('./utils/configFile');
const installVsix = (isInsiders, buildNum) => {
if (!configExists()) {
error('The cli is not properly configured. Try running $ctv setup --help');
process.exit(1);
}
const cliConfig = readConfigFile();
const opts = buildHTTPOpts(buildNum, cliConfig);
httpsGet(opts).then(jsonData => {
if (jsonData.length > 0) {
info(`VSIXs to be downloaded : ${jsonData.length}`);
}
for (let i = 0; i < jsonData.length; i++) {
try {
const vsixName = getVsixName(jsonData[i]);
const downloadURL = jsonData[i].url;
const dwn = download(vsixName, downloadURL);
extract(dwn[0], dwn[1], isInsiders);
} catch (e) {
error(e.message);
}
}
});
};
module.exports = { installVsix };