-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
launch: check prerequisites in a pre-launch task
Fixes #103708
- Loading branch information
1 parent
98dd195
commit 262ab80
Showing
9 changed files
with
158 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// @ts-check | ||
const path = require("path"); | ||
const child_process_1 = require("child_process"); | ||
const fs_1 = require("fs"); | ||
const yarn = process.platform === 'win32' ? 'yarn.cmd' : 'yarn'; | ||
const rootDir = path.resolve(__dirname, '..', '..'); | ||
function runProcess(command, args = []) { | ||
return new Promise((resolve, reject) => { | ||
const child = child_process_1.spawn(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env }); | ||
child.on('exit', err => !err ? resolve() : process.exit(err !== null && err !== void 0 ? err : 1)); | ||
child.on('error', reject); | ||
}); | ||
} | ||
async function exists(subdir) { | ||
try { | ||
await fs_1.promises.stat(path.join(rootDir, subdir)); | ||
return true; | ||
} | ||
catch (_a) { | ||
return false; | ||
} | ||
} | ||
async function ensureNodeModules() { | ||
if (!(await exists('node_modules'))) { | ||
await runProcess(yarn); | ||
} | ||
} | ||
async function getElectron() { | ||
await runProcess(yarn, ['electron']); | ||
} | ||
async function ensureCompiled() { | ||
if (!(await exists('out'))) { | ||
await runProcess(yarn, ['compile']); | ||
} | ||
} | ||
async function main() { | ||
await ensureNodeModules(); | ||
await getElectron(); | ||
await ensureCompiled(); | ||
// Can't require this until after dependencies are installed | ||
const { getBuiltInExtensions } = require('./builtInExtensions'); | ||
await getBuiltInExtensions(); | ||
} | ||
if (require.main === module) { | ||
main().catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
// @ts-check | ||
|
||
import * as path from 'path'; | ||
import { spawn } from 'child_process'; | ||
import { promises as fs } from 'fs'; | ||
|
||
const yarn = process.platform === 'win32' ? 'yarn.cmd' : 'yarn'; | ||
const rootDir = path.resolve(__dirname, '..', '..'); | ||
|
||
function runProcess(command: string, args: ReadonlyArray<string> = []) { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env }); | ||
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(yarn); | ||
} | ||
} | ||
|
||
async function getElectron() { | ||
await runProcess(yarn, ['electron']); | ||
} | ||
|
||
async function ensureCompiled() { | ||
if (!(await exists('out'))) { | ||
await runProcess(yarn, ['compile']); | ||
} | ||
} | ||
|
||
async function main() { | ||
await ensureNodeModules(); | ||
await getElectron(); | ||
await ensureCompiled(); | ||
|
||
// Can't require this until after dependencies are installed | ||
const { getBuiltInExtensions } = require('./builtInExtensions'); | ||
await getBuiltInExtensions(); | ||
} | ||
|
||
if (require.main === module) { | ||
main().catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters