From e041ac6f0d8c519d104601b2b49c008721c074b7 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Sun, 12 Apr 2020 14:55:57 +0300 Subject: [PATCH] fix(ngcc): display output from the unlocker process on Windows (#36569) On Windows, the output of a detached process (such as the unlocker process used by `LockFileWithChildProcess`) is not shown in the parent process' stdout. This commit addresses this by piping the spawned process' stdin/stdout and manually writing to the parent process' stdout. PR Close #36569 --- .../locking/lock_file_with_child_process/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/locking/lock_file_with_child_process/index.ts b/packages/compiler-cli/ngcc/src/locking/lock_file_with_child_process/index.ts index 9827343db9..a544addf0d 100644 --- a/packages/compiler-cli/ngcc/src/locking/lock_file_with_child_process/index.ts +++ b/packages/compiler-cli/ngcc/src/locking/lock_file_with_child_process/index.ts @@ -5,7 +5,8 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import {ChildProcess, fork} from 'child_process'; +import {ChildProcess, ChildProcessByStdio, fork} from 'child_process'; +import {Readable, Writable} from 'stream'; import {AbsoluteFsPath, CachedFileSystem, FileSystem} from '../../../../src/ngtsc/file_system'; import {Logger, LogLevel} from '../../logging/logger'; @@ -81,6 +82,14 @@ export class LockFileWithChildProcess implements LockFile { this.logger.debug('Forking unlocker child-process'); const logLevel = this.logger.level !== undefined ? this.logger.level.toString() : LogLevel.info.toString(); - return fork(this.fs.resolve(__dirname, './unlocker.js'), [path, logLevel], {detached: true}); + + const unlocker = fork(this.fs.resolve(__dirname, './unlocker.js'), [path, logLevel], { + detached: true, + stdio: 'pipe', + }) as ChildProcessByStdio; + unlocker.stdout.on('data', data => process.stdout.write(data)); + unlocker.stderr.on('data', data => process.stderr.write(data)); + + return unlocker; } }