forked from redhat-developer/vscode-openshift-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle-tools.ts
More file actions
50 lines (47 loc) · 1.96 KB
/
bundle-tools.ts
File metadata and controls
50 lines (47 loc) · 1.96 KB
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
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-console */
import * as fs from 'fs';
import * as path from 'path';
import { exit } from 'process';
import { downloadFileAndCreateSha256 } from '../src/downloadUtil/downloadBinaries';
import * as configData from '../src/tools.json';
async function bundleTools(): Promise<void> {
if (process.env.REMOTE_CONTAINERS === 'true') {
return;
}
const outFolder = path.resolve('.', 'out');
const toolsCacheFolder = path.join(outFolder, 'tools-cache');
let currentPlatform = process.env.TARGET;
if (!currentPlatform) {
currentPlatform = process.argv.find((arg) => arg === '--platform')
? process.platform
: 'all';
}
console.log(currentPlatform);
console.info(`Download tools to '${toolsCacheFolder}'`);
for (const key in configData) {
const tool = configData[key];
for (const OS in tool.platform) {
if (currentPlatform === 'all' || OS === currentPlatform) {
console.log(`Bundle '${tool.description}' for ${OS}`);
const osSpecificLocation = path.join(outFolder, 'tools', OS);
// eslint-disable-next-line no-await-in-loop
await downloadFileAndCreateSha256(
toolsCacheFolder,
osSpecificLocation,
tool.platform[OS],
);
fs.chmodSync(path.join(osSpecificLocation, tool.platform[OS].cmdFileName), 0o765);
}
}
}
}
bundleTools().catch((error) => {
console.log(error);
exit(1);
});