Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/Shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ class Shell extends EventEmitter {
const proc = spawn(`${psProc}${!isWin ? '' : '.exe'}`, psOpts, { stdio: 'pipe' });
this.pid = proc.pid;

proc.once('error', () => {
// if this.pid is absent an error will already have been emitted
if (this.pid) this.emit('error', new PS_PROC_ERROR());
});

// make sure the PS process start successfully
if(!this.pid) {
this.emit('error', new PS_PROC_ERROR());
return;
}
proc.once('error', () => {
this.emit('error', new PS_PROC_ERROR());
});


// set streams encoding
proc.stdin.setDefaultEncoding(options.inputEncoding || 'utf8');
Expand Down