Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/win32/explorer-dll-fetcher.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
'use strict';
7
8
import fs from 'fs';
9
import debug from 'debug';
10
import path from 'path';
11
import { downloadArtifact } from '@electron/get';
12
import product from '../../product.json';
13
14
const d = debug('explorer-dll-fetcher');
15
16
export async function downloadExplorerDll(outDir: string, quality: string = 'stable', targetArch: string = 'x64'): Promise<void> {
17
const fileNamePrefix = quality === 'insider' ? 'code_insider' : 'code';
18
const fileName = `${fileNamePrefix}_explorer_command_${targetArch}.dll`;
19
20
if (!await fs.existsSync(outDir)) {
21
await fs.mkdirSync(outDir, { recursive: true });
22
}
23
24
// Read and parse checksums file
25
const checksumsFilePath = path.join(path.dirname(__dirname), 'checksums', 'explorer-dll.txt');
26
const checksumsContent = fs.readFileSync(checksumsFilePath, 'utf8');
27
const checksums: Record<string, string> = {};
28
29
checksumsContent.split('\n').forEach(line => {
30
const trimmedLine = line.trim();
31
if (trimmedLine) {
32
const [checksum, filename] = trimmedLine.split(/\s+/);
33
if (checksum && filename) {
34
checksums[filename] = checksum;
35
}
36
}
37
});
38
39
d(`downloading ${fileName}`);
40
const artifact = await downloadArtifact({
41
isGeneric: true,
42
version: 'v4.0.0-350164',
43
artifactName: fileName,
44
checksums,
45
mirrorOptions: {
46
mirror: 'https://github.com/microsoft/vscode-explorer-command/releases/download/',
47
customDir: 'v4.0.0-350164',
48
customFilename: fileName
49
}
50
});
51
52
d(`moving ${artifact} to ${outDir}`);
53
await fs.copyFileSync(artifact, path.join(outDir, fileName));
54
}
55
56
async function main(outputDir?: string): Promise<void> {
57
const arch = process.env['VSCODE_ARCH'];
58
59
if (!outputDir) {
60
throw new Error('Required build env not set');
61
}
62
63
await downloadExplorerDll(outputDir, (product as any).quality, arch);
64
}
65
66
if (require.main === module) {
67
main(process.argv[2]).catch(err => {
68
console.error(err);
69
process.exit(1);
70
});
71
}
72
73