Skip to content

Commit e041ac6

Browse files
gkalpakatscott
authored andcommittedApr 15, 2020
fix(ngcc): display output from the unlocker process on Windows (angular#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 angular#36569

File tree

1 file changed

+11
-2
lines changed
  • packages/compiler-cli/ngcc/src/locking/lock_file_with_child_process

1 file changed

+11
-2
lines changed
 

‎packages/compiler-cli/ngcc/src/locking/lock_file_with_child_process/index.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import {ChildProcess, fork} from 'child_process';
8+
import {ChildProcess, ChildProcessByStdio, fork} from 'child_process';
9+
import {Readable, Writable} from 'stream';
910

1011
import {AbsoluteFsPath, CachedFileSystem, FileSystem} from '../../../../src/ngtsc/file_system';
1112
import {Logger, LogLevel} from '../../logging/logger';
@@ -81,6 +82,14 @@ export class LockFileWithChildProcess implements LockFile {
8182
this.logger.debug('Forking unlocker child-process');
8283
const logLevel =
8384
this.logger.level !== undefined ? this.logger.level.toString() : LogLevel.info.toString();
84-
return fork(this.fs.resolve(__dirname, './unlocker.js'), [path, logLevel], {detached: true});
85+
86+
const unlocker = fork(this.fs.resolve(__dirname, './unlocker.js'), [path, logLevel], {
87+
detached: true,
88+
stdio: 'pipe',
89+
}) as ChildProcessByStdio<Writable, Readable, Readable>;
90+
unlocker.stdout.on('data', data => process.stdout.write(data));
91+
unlocker.stderr.on('data', data => process.stderr.write(data));
92+
93+
return unlocker;
8594
}
8695
}

0 commit comments

Comments
 (0)
Please sign in to comment.