[Pkg-javascript-commits] [node-foreground-child] 07/69: beforeExit hook
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Aug 25 11:43:01 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-foreground-child.
commit d60c88e59f549d476c542de806b507513d1151af
Author: Benjamin Coe <ben at npmjs.com>
Date: Wed Jun 17 17:54:22 2015 -0400
beforeExit hook
---
index.js | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/index.js b/index.js
index e7e5d0a..dd50b0e 100644
--- a/index.js
+++ b/index.js
@@ -1,7 +1,17 @@
var signalExit = require('signal-exit')
var spawn = require('child_process').spawn
-module.exports = function (program, args) {
+module.exports = function (program, args, cb) {
+
+ if (typeof args === 'function') {
+ cb = args
+ args = undefined
+ }
+
+ cb = cb || function (done) {
+ return done()
+ }
+
if (Array.isArray(program)) {
args = program.slice(1)
program = program[0]
@@ -17,17 +27,19 @@ module.exports = function (program, args) {
})
child.on('close', function (code, signal) {
- childExited = true
- if (signal) {
- // If there is nothing else keeping the event loop alive,
- // then there's a race between a graceful exit and getting
- // the signal to this process. Put this timeout here to
- // make sure we're still alive to get the signal, and thus
- // exit with the intended signal code.
- setTimeout(function () {}, 200)
- process.kill(process.pid, signal)
- } else
- process.exit(code)
+ cb(function () {
+ childExited = true
+ if (signal) {
+ // If there is nothing else keeping the event loop alive,
+ // then there's a race between a graceful exit and getting
+ // the signal to this process. Put this timeout here to
+ // make sure we're still alive to get the signal, and thus
+ // exit with the intended signal code.
+ setTimeout(function () {}, 200)
+ process.kill(process.pid, signal)
+ } else
+ process.exit(code)
+ })
})
return child
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-foreground-child.git
More information about the Pkg-javascript-commits
mailing list