mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Use pipe for WSL2 (#194010)
This commit is contained in:
committed by
GitHub
parent
35a34cd1f3
commit
1b5c0af328
@@ -86,7 +86,6 @@ const cliCommandCwd = process.env['VSCODE_CLIENT_COMMAND_CWD'] as string;
|
|||||||
const cliRemoteAuthority = process.env['VSCODE_CLI_AUTHORITY'] as string;
|
const cliRemoteAuthority = process.env['VSCODE_CLI_AUTHORITY'] as string;
|
||||||
const cliStdInFilePath = process.env['VSCODE_STDIN_FILE_PATH'] as string;
|
const cliStdInFilePath = process.env['VSCODE_STDIN_FILE_PATH'] as string;
|
||||||
|
|
||||||
|
|
||||||
export async function main(desc: ProductDescription, args: string[]): Promise<void> {
|
export async function main(desc: ProductDescription, args: string[]): Promise<void> {
|
||||||
if (!cliPipe && !cliCommand) {
|
if (!cliPipe && !cliCommand) {
|
||||||
console.log('Command is only available in WSL or inside a Visual Studio Code terminal.');
|
console.log('Command is only available in WSL or inside a Visual Studio Code terminal.');
|
||||||
@@ -271,7 +270,16 @@ export async function main(desc: ProductDescription, args: string[]): Promise<vo
|
|||||||
if (verbose) {
|
if (verbose) {
|
||||||
console.log(`Invoking: cd "${cliCwd}" && ELECTRON_RUN_AS_NODE=1 "${cliCommand}" "${newCommandline.join('" "')}"`);
|
console.log(`Invoking: cd "${cliCwd}" && ELECTRON_RUN_AS_NODE=1 "${cliCommand}" "${newCommandline.join('" "')}"`);
|
||||||
}
|
}
|
||||||
_cp.spawn(cliCommand, newCommandline, { cwd: cliCwd, env, stdio: ['inherit'] });
|
if (runningInWSL2()) {
|
||||||
|
if (verbose) {
|
||||||
|
console.log(`Using pipes for output.`);
|
||||||
|
}
|
||||||
|
const cp = _cp.spawn(cliCommand, newCommandline, { cwd: cliCwd, env, stdio: ['inherit', 'pipe', 'pipe'] });
|
||||||
|
cp.stdout.on('data', data => process.stdout.write(data));
|
||||||
|
cp.stderr.on('data', data => process.stderr.write(data));
|
||||||
|
} else {
|
||||||
|
_cp.spawn(cliCommand, newCommandline, { cwd: cliCwd, env, stdio: 'inherit' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (parsedArgs.status) {
|
if (parsedArgs.status) {
|
||||||
@@ -331,6 +339,17 @@ export async function main(desc: ProductDescription, args: string[]): Promise<vo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runningInWSL2(): boolean {
|
||||||
|
if (!!process.env['WSL_DISTRO_NAME']) {
|
||||||
|
try {
|
||||||
|
return _cp.execSync('uname -r', { encoding: 'utf8' }).includes('-microsoft-');
|
||||||
|
} catch (_e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
async function waitForFileDeleted(path: string) {
|
async function waitForFileDeleted(path: string) {
|
||||||
while (_fs.existsSync(path)) {
|
while (_fs.existsSync(path)) {
|
||||||
await new Promise(res => setTimeout(res, 1000));
|
await new Promise(res => setTimeout(res, 1000));
|
||||||
|
|||||||
Reference in New Issue
Block a user