Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/lib/preLaunch.js
3520 views
1
"use strict";
2
var __importDefault = (this && this.__importDefault) || function (mod) {
3
return (mod && mod.__esModule) ? mod : { "default": mod };
4
};
5
Object.defineProperty(exports, "__esModule", { value: true });
6
/*---------------------------------------------------------------------------------------------
7
* Copyright (c) Microsoft Corporation. All rights reserved.
8
* Licensed under the MIT License. See License.txt in the project root for license information.
9
*--------------------------------------------------------------------------------------------*/
10
// @ts-check
11
const path_1 = __importDefault(require("path"));
12
const child_process_1 = require("child_process");
13
const fs_1 = require("fs");
14
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
15
const rootDir = path_1.default.resolve(__dirname, '..', '..');
16
function runProcess(command, args = []) {
17
return new Promise((resolve, reject) => {
18
const child = (0, child_process_1.spawn)(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env, shell: process.platform === 'win32' });
19
child.on('exit', err => !err ? resolve() : process.exit(err ?? 1));
20
child.on('error', reject);
21
});
22
}
23
async function exists(subdir) {
24
try {
25
await fs_1.promises.stat(path_1.default.join(rootDir, subdir));
26
return true;
27
}
28
catch {
29
return false;
30
}
31
}
32
async function ensureNodeModules() {
33
if (!(await exists('node_modules'))) {
34
await runProcess(npm, ['ci']);
35
}
36
}
37
async function getElectron() {
38
await runProcess(npm, ['run', 'electron']);
39
}
40
async function ensureCompiled() {
41
if (!(await exists('out'))) {
42
await runProcess(npm, ['run', 'compile']);
43
}
44
}
45
async function main() {
46
await ensureNodeModules();
47
await getElectron();
48
await ensureCompiled();
49
// Can't require this until after dependencies are installed
50
const { getBuiltInExtensions } = require('./builtInExtensions');
51
await getBuiltInExtensions();
52
}
53
if (require.main === module) {
54
main().catch(err => {
55
console.error(err);
56
process.exit(1);
57
});
58
}
59
//# sourceMappingURL=preLaunch.js.map
60