Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

View File

@ -0,0 +1,93 @@
# Changes
## v1.5.6
* Fix 'childHangup is undefined'
## v1.5.5
* add files list to package.json
* neveragain.tech pledge request
## v1.5.4
* update tap to v8
* Let the child decide if signals should be fatal
## v1.5.3
* bump deps
## v1.5.2
* add an automatic changelog script
* replace cross-spawn-async with cross-spawn
* test: stay alive long enough to be signaled
## v1.5.1
* avoid race condition in test
* Use fd numbers instead of 'inherit' for Node v0.10 compatibility
## v1.5.0
* add caveats re IPC and arbitrary FDs
* Forward IPC messages to foregrounded child process
## v1.4.0
* Set `process.exitCode` based on the childs exit code
## v1.3.5
* Better testing for when cross-spawn-async needed
* appveyor: node v0.10 on windows is too flaky
## v1.3.4
* Only use cross-spawn-async for shebangs
* update vanity badges and package.json for repo move
* appveyor
## v1.3.3
* Skip signals in tests on Windows
* update to tap@4
* use cross-spawn-async on windows
## v1.3.2
* Revert "switch to win-spawn"
* Revert "Transparently translate high-order exit code to appropriate signal"
* update travis versions
* Transparently translate high-order exit code to appropriate signal
* ignore coverage folder
## v1.3.1
* switch to win-spawn
## v1.3.0
* note skipped test in test output
* left an unused var c in
* slice arguments, added documentation
* added a unit test, because I strive to be a good open-source-citizen
* make travis also work on 0.12 and iojs again
* added badge
* patch for travis exit weirdness
* fix typo in .gitignore
* beforeExit hook
## v1.2.0
* Use signal-exit, fix kill(process.pid) race
## v1.1.0
* Enforce that parent always gets a 'exit' event
## v1.0.0
* first

View File

@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -0,0 +1,52 @@
# foreground-child
[![Build Status](https://travis-ci.org/tapjs/foreground-child.svg)](https://travis-ci.org/tapjs/foreground-child) [![Build status](https://ci.appveyor.com/api/projects/status/kq9ylvx9fyr9khx0?svg=true)](https://ci.appveyor.com/project/isaacs/foreground-child)
Run a child as if it's the foreground process. Give it stdio. Exit
when it exits.
Mostly this module is here to support some use cases around wrapping
child processes for test coverage and such.
## USAGE
```js
var foreground = require('foreground-child')
// cats out this file
var child = foreground('cat', [__filename])
// At this point, it's best to just do nothing else.
// return or whatever.
// If the child gets a signal, or just exits, then this
// parent process will exit in the same way.
```
A callback can optionally be provided, if you want to perform an action
before your foreground-child exits:
```js
var child = foreground('cat', [__filename], function (done) {
// perform an action.
return done()
})
```
## Caveats
The "normal" standard IO file descriptors (0, 1, and 2 for stdin,
stdout, and stderr respectively) are shared with the child process.
Additionally, if there is an IPC channel set up in the parent, then
messages are proxied to the child on file descriptor 3.
However, in Node, it's possible to also map arbitrary file descriptors
into a child process. In these cases, foreground-child will not map
the file descriptors into the child. If file descriptors 0, 1, or 2
are used for the IPC channel, then strange behavior may happen (like
printing IPC messages to stderr, for example).
Note that a SIGKILL will always kill the parent process, _and never
the child process_, because SIGKILL cannot be caught or proxied. The
only way to do this would be if Node provided a way to truly exec a
process as the new foreground program in the same process space,
without forking a separate child process.

View File

@ -0,0 +1,10 @@
#!/bin/bash
(
echo '# Changes'
echo ''
git log --first-parent --pretty=format:'%s' \
| grep -v '^update changelog' \
| grep -v 'beta' \
| perl -p -e 's/^((v?[0-9]+\.?)+)?$/\n## \1\n/g' \
| perl -p -e 's/^([^#\s].*)$/* \1/g'
)> CHANGELOG.md

View File

@ -0,0 +1,102 @@
var signalExit = require('signal-exit')
var spawn = require('child_process').spawn
if (process.platform === 'win32') {
spawn = require('cross-spawn')
}
module.exports = function (program, args, cb) {
var arrayIndex = arguments.length
if (typeof args === 'function') {
cb = args
args = undefined
} else {
cb = Array.prototype.slice.call(arguments).filter(function (arg, i) {
if (typeof arg === 'function') {
arrayIndex = i
return true
}
})[0]
}
cb = cb || function (done) {
return done()
}
if (Array.isArray(program)) {
args = program.slice(1)
program = program[0]
} else if (!Array.isArray(args)) {
args = [].slice.call(arguments, 1, arrayIndex)
}
var spawnOpts = { stdio: [0, 1, 2] }
if (process.send) {
spawnOpts.stdio.push('ipc')
}
var child = spawn(program, args, spawnOpts)
var childExited = false
var unproxySignals = proxySignals(child)
process.on('exit', childHangup)
function childHangup () {
child.kill('SIGHUP')
}
child.on('close', function (code, signal) {
// Allow the callback to inspect the childs exit code and/or modify it.
process.exitCode = signal ? 128 + signal : code
cb(function () {
unproxySignals()
process.removeListener('exit', childHangup)
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 {
// Equivalent to process.exit() on Node.js >= 0.11.8
process.exit(process.exitCode)
}
})
})
if (process.send) {
process.removeAllListeners('message')
child.on('message', function (message, sendHandle) {
process.send(message, sendHandle)
})
process.on('message', function (message, sendHandle) {
child.send(message, sendHandle)
})
}
return child
}
function proxySignals (child) {
var listeners = {}
signalExit.signals().forEach(function (sig) {
listeners[sig] = function () {
child.kill(sig)
}
process.on(sig, listeners[sig])
})
return unproxySignals
function unproxySignals () {
for (var sig in listeners) {
process.removeListener(sig, listeners[sig])
}
}
}

View File

@ -0,0 +1,63 @@
{
"_from": "foreground-child@^1.3.3",
"_id": "foreground-child@1.5.6",
"_inBundle": false,
"_integrity": "sha1-T9ca0t/elnibmApcCilZN8svXOk=",
"_location": "/foreground-child",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "foreground-child@^1.3.3",
"name": "foreground-child",
"escapedName": "foreground-child",
"rawSpec": "^1.3.3",
"saveSpec": null,
"fetchSpec": "^1.3.3"
},
"_requiredBy": [
"/tap"
],
"_resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-1.5.6.tgz",
"_shasum": "4fd71ad2dfde96789b980a5c0a295937cb2f5ce9",
"_spec": "foreground-child@^1.3.3",
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/tap",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/tapjs/foreground-child/issues"
},
"bundleDependencies": false,
"dependencies": {
"cross-spawn": "^4",
"signal-exit": "^3.0.0"
},
"deprecated": false,
"description": "Run a child as if it's the foreground process. Give it stdio. Exit when it exits.",
"devDependencies": {
"tap": "^8.0.1"
},
"directories": {
"test": "test"
},
"files": [
"index.js"
],
"homepage": "https://github.com/tapjs/foreground-child#readme",
"license": "ISC",
"main": "index.js",
"name": "foreground-child",
"repository": {
"type": "git",
"url": "git+https://github.com/tapjs/foreground-child.git"
},
"scripts": {
"changelog": "bash changelog.sh",
"postversion": "npm run changelog && git add CHANGELOG.md && git commit -m 'update changelog - '${npm_package_version}",
"test": "tap --coverage test/*.js"
},
"version": "1.5.6"
}