Last active
August 29, 2015 14:12
-
-
Save heikki/8b11d5bb918ecb9de6bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"exit": "^0.1.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// https://github.com/cowboy/node-exit | |
var exit = require('exit'); | |
console.log('before'); | |
process.on('exit', function() { | |
console.log('on exit'); | |
}); | |
console.log('after'); | |
exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
console.log('before'); | |
process.on('exit', function() { | |
console.log('on exit'); | |
}); | |
console.log('after'); | |
process.exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// From https://github.com/airportyh/testem/blob/master/lib/clean_exit.js | |
function exit(code) { | |
var draining = 0; | |
var onDrain = function() { | |
if (!(draining--)) { | |
process.exit(code); | |
} | |
}; | |
if (process.stdout.bufferSize) { | |
draining++; | |
process.stdout.once('drain', onDrain); | |
} | |
if (process.stderr.bufferSize) { | |
draining++; | |
process.stderr.once('drain', onDrain); | |
} | |
if (!draining) { | |
process.exit(code); | |
} | |
} | |
console.log('before'); | |
process.on('exit', function() { | |
console.log('on exit'); | |
}); | |
console.log('after'); | |
exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var child = require('child_process'); | |
child.exec('node test-process-exit.js', function(stderr, stdout) { | |
console.log('\n--- process.exit, stdout is truncated on windows ---'); | |
console.log('stderr:', stderr); | |
console.log('stdout:', stdout); | |
}); | |
child.exec('node test-node-exit.js', function(stderr, stdout) { | |
console.log('\n--- node-exit, \'on exit\' is missing ---'); | |
console.log('stderr:', stderr); | |
console.log('stdout:', stdout); | |
}); | |
child.exec('node test-testem-exit.js', function(stderr, stdout) { | |
console.log('\n--- testem exit, all ok? ---'); | |
console.log('stderr:', stderr); | |
console.log('stdout:', stdout); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment