Skip to content

Commit 05ae089

Browse files
authored
fix: reading from console output for --status on windows and linux (microsoft#184138)
fix: reading from console output for --status on windows and linux (microsoft#184118)
1 parent e0edacb commit 05ae089

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/vs/code/node/cli.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,14 @@ export async function main(argv: string[]): Promise<any> {
188188

189189
const processCallbacks: ((child: ChildProcess) => Promise<void>)[] = [];
190190

191-
const verbose = args.verbose;
192-
if (verbose) {
191+
if (args.verbose) {
193192
env['ELECTRON_ENABLE_LOGGING'] = '1';
193+
}
194194

195+
if (args.verbose || args.status) {
195196
processCallbacks.push(async child => {
196197
child.stdout!.on('data', (data: Buffer) => console.log(data.toString('utf8').trim()));
197-
child.stderr!.on('data', (data: Buffer) => console.log(data.toString('utf8').trim()));
198+
child.stderr?.on('data', (data: Buffer) => console.log(data.toString('utf8').trim()));
198199

199200
await Event.toPromise(Event.fromNodeEventEmitter(child, 'exit'));
200201
});
@@ -219,7 +220,7 @@ export async function main(argv: string[]): Promise<any> {
219220

220221
// returns a file path where stdin input is written into (write in progress).
221222
try {
222-
await readFromStdin(stdinFilePath, !!verbose); // throws error if file can not be written
223+
await readFromStdin(stdinFilePath, !!args.verbose); // throws error if file can not be written
223224

224225
// Make sure to open tmp file
225226
addArg(argv, stdinFilePath);
@@ -258,7 +259,7 @@ export async function main(argv: string[]): Promise<any> {
258259
// is closed and then exit the waiting process.
259260
let waitMarkerFilePath: string | undefined;
260261
if (args.wait) {
261-
waitMarkerFilePath = createWaitMarkerFileSync(verbose);
262+
waitMarkerFilePath = createWaitMarkerFileSync(args.verbose);
262263
if (waitMarkerFilePath) {
263264
addArg(argv, '--waitMarkerFilePath', waitMarkerFilePath);
264265
}
@@ -407,13 +408,13 @@ export async function main(argv: string[]): Promise<any> {
407408
env
408409
};
409410

410-
if (!verbose) {
411+
if (!args.verbose) {
411412
options['stdio'] = 'ignore';
412413
}
413414

414415
let child: ChildProcess;
415416
if (!isMacOSBigSurOrNewer) {
416-
if (!verbose && args.status) {
417+
if (!args.verbose && args.status) {
417418
options['stdio'] = ['ignore', 'pipe', 'ignore']; // restore ability to see output when --status is used
418419
}
419420

@@ -435,13 +436,13 @@ export async function main(argv: string[]): Promise<any> {
435436
// -a opens the given application.
436437
spawnArgs.push('-a', process.execPath); // -a: opens a specific application
437438

438-
if (verbose || args.status) {
439+
if (args.verbose || args.status) {
439440
spawnArgs.push('--wait-apps'); // `open --wait-apps`: blocks until the launched app is closed (even if they were already running)
440441

441442
// The open command only allows for redirecting stderr and stdout to files,
442443
// so we make it redirect those to temp files, and then use a logger to
443444
// redirect the file output to the console
444-
for (const outputType of verbose ? ['stdout', 'stderr'] : ['stdout']) {
445+
for (const outputType of args.verbose ? ['stdout', 'stderr'] : ['stdout']) {
445446

446447
// Tmp file to target output to
447448
const tmpName = randomPath(tmpdir(), `code-${outputType}`);

0 commit comments

Comments
 (0)