|
| 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 | +'use strict'; |
| 6 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 7 | +// @ts-check |
| 8 | +const path = require("path"); |
| 9 | +const child_process_1 = require("child_process"); |
| 10 | +const fs_1 = require("fs"); |
| 11 | +const yarn = process.platform === 'win32' ? 'yarn.cmd' : 'yarn'; |
| 12 | +const rootDir = path.resolve(__dirname, '..', '..'); |
| 13 | +function runProcess(command, args = []) { |
| 14 | + return new Promise((resolve, reject) => { |
| 15 | + const child = child_process_1.spawn(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env }); |
| 16 | + child.on('exit', err => !err ? resolve() : process.exit(err !== null && err !== void 0 ? err : 1)); |
| 17 | + child.on('error', reject); |
| 18 | + }); |
| 19 | +} |
| 20 | +async function exists(subdir) { |
| 21 | + try { |
| 22 | + await fs_1.promises.stat(path.join(rootDir, subdir)); |
| 23 | + return true; |
| 24 | + } |
| 25 | + catch (_a) { |
| 26 | + return false; |
| 27 | + } |
| 28 | +} |
| 29 | +async function ensureNodeModules() { |
| 30 | + if (!(await exists('node_modules'))) { |
| 31 | + await runProcess(yarn); |
| 32 | + } |
| 33 | +} |
| 34 | +async function getElectron() { |
| 35 | + await runProcess(yarn, ['electron']); |
| 36 | +} |
| 37 | +async function ensureCompiled() { |
| 38 | + if (!(await exists('out'))) { |
| 39 | + await runProcess(yarn, ['compile']); |
| 40 | + } |
| 41 | +} |
| 42 | +async function main() { |
| 43 | + await ensureNodeModules(); |
| 44 | + await getElectron(); |
| 45 | + await ensureCompiled(); |
| 46 | + // Can't require this until after dependencies are installed |
| 47 | + const { getBuiltInExtensions } = require('./builtInExtensions'); |
| 48 | + await getBuiltInExtensions(); |
| 49 | +} |
| 50 | +if (require.main === module) { |
| 51 | + main().catch(err => { |
| 52 | + console.error(err); |
| 53 | + process.exit(1); |
| 54 | + }); |
| 55 | +} |
0 commit comments