mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 10:19:02 +00:00
* Run our build scripts directly as typescript #277567 Follow up on #276864 For #277526 * Remove a few more ts-node references * Fix linux and script reference * Remove `_build-script` ref * Fix script missing closing quote * use type only import * Fix export * Make sure to run copy-policy-dto * Make sure we run the copy-policy-dto script * Enable `verbatimModuleSyntax` * Pipelines fixes * Try adding explicit ext to path * Fix bad edit * Revert extra `--` --------- Co-authored-by: João Moreno <joaomoreno@users.noreply.github.com>
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
import path from 'path';
|
|
import { spawn } from 'child_process';
|
|
import { promises as fs } from 'fs';
|
|
|
|
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
const rootDir = path.resolve(import.meta.dirname, '..', '..');
|
|
|
|
function runProcess(command: string, args: ReadonlyArray<string> = []) {
|
|
return new Promise<void>((resolve, reject) => {
|
|
const child = spawn(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env, shell: process.platform === 'win32' });
|
|
child.on('exit', err => !err ? resolve() : process.exit(err ?? 1));
|
|
child.on('error', reject);
|
|
});
|
|
}
|
|
|
|
async function exists(subdir: string) {
|
|
try {
|
|
await fs.stat(path.join(rootDir, subdir));
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
async function ensureNodeModules() {
|
|
if (!(await exists('node_modules'))) {
|
|
await runProcess(npm, ['ci']);
|
|
}
|
|
}
|
|
|
|
async function getElectron() {
|
|
await runProcess(npm, ['run', 'electron']);
|
|
}
|
|
|
|
async function ensureCompiled() {
|
|
if (!(await exists('out'))) {
|
|
await runProcess(npm, ['run', 'compile']);
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
await ensureNodeModules();
|
|
await getElectron();
|
|
await ensureCompiled();
|
|
|
|
// Can't require this until after dependencies are installed
|
|
const { getBuiltInExtensions } = await import('./builtInExtensions.ts');
|
|
await getBuiltInExtensions();
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
main().catch(err => {
|
|
console.error(err);
|
|
process.exit(1);
|
|
});
|
|
}
|