Skip to content

Commit

Permalink
Merge pull request #2 from mitchhentges/process-close
Browse files Browse the repository at this point in the history
Use process `close`, not process `exit`, so stdout can be flushed
  • Loading branch information
tomitm committed Feb 26, 2016
2 parents c14e680 + 89d0873 commit f491364
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Upcoming Release

#### Breaking changes
`stop` event is now emitted on process `close`, not process `exit` (so that stdout can be flushed first)

#### User features
- Detect `Canary` on `OSX` (i: @caitp, r: @mitchhentges)
- Support launching `phantomjs` on `OSX` (i: @epmatsw, r: @mitchhentges)
- Detect `Chromium` on `OSX` (i: @rhendric, r: @mitchhentges)
- `IE` will now response to `stop()` (i: @vsashidh, r: @mitchhentges)

#### Developer features
- None yet

#### Bugfixes
- Docs updated to describe how `james-browser-launcher` compares to other launchers (i: @mitchhentges, r: @tomitm)

# 1.0.0
- First release as `james-browser-launcher`
2 changes: 1 addition & 1 deletion lib/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function checkOthers( name, callback ) {
callback = null;
} );

process.on( 'exit', function( code ) {
process.on( 'close', function( code ) {
if ( !callback ) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Instance( options ) {
}

// trigger "stop" event when the process exits
this.process.on( 'exit', this.emit.bind( this, 'stop' ) );
this.process.on( 'close', this.emit.bind( this, 'stop' ) );

// clean-up the temp directory once the instance stops
if ( this.tempDir ) {
Expand All @@ -66,11 +66,11 @@ Instance.prototype.stop = function( callback ) {
// Opera case - it uses a launcher so we have to kill it somehow without a reference to the process
if ( process.platform === 'win32' && this.image ) {
child.exec( 'taskkill /F /IM ' + this.image )
.on( 'exit', this.emit.bind( this, 'stop' ) );
.on( 'close', this.emit.bind( this, 'stop' ) );
// ie case on windows machine
} else if ( process.platform === 'win32' && this.browserType === 'ie' ) {
child.exec( 'taskkill /F /IM iexplore.exe')
.on( 'exit', this.emit.bind( this, 'stop' ) );
.on( 'close', this.emit.bind( this, 'stop' ) );
// OSX case with "open" command
} else if ( this.command === 'open' ) {
child.exec( 'osascript -e \'tell application "' + this.processName + '" to quit\'' );
Expand Down

0 comments on commit f491364

Please sign in to comment.