Skip to content

Commit

Permalink
Merge branch 'main' into feat/watchdog-info
Browse files Browse the repository at this point in the history
  • Loading branch information
frattaro authored Jul 12, 2024
2 parents b272753 + 132a017 commit d0273cc
Show file tree
Hide file tree
Showing 30 changed files with 4,153 additions and 3,673 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 19.x]
node-version: [18.x, 20.x, 22.x]
platform:
- os: ubuntu-latest
shell: bash
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
/.tap
.DS_Store
/coverage
/dist
/node_modules
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
/.tshy
/example
/.github
/dist
Expand All @@ -7,3 +8,6 @@
/.nyc_output
/coverage
/benchmark
/test/fixtures/*.d.ts
/test/fixtures/*.js
/test/fixtures/*.map
8 changes: 8 additions & 0 deletions .tshy/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../src",
"module": "nodenext",
"moduleResolution": "nodenext"
}
}
14 changes: 14 additions & 0 deletions .tshy/commonjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
],
"exclude": [
"../src/**/*.mts"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
}
}
12 changes: 12 additions & 0 deletions .tshy/esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## v3.2

- Export `watchdog` and `proxySignals` functionality

## v3.1

- Add support for optional SpawnOptions param
Expand Down
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,41 @@ status code rather than reporting the signal properly. This
module tries to do the right thing, but on Windows systems, you
may see that incorrect result. There is as far as I'm aware no
workaround for this.

## util: `foreground-child/proxy-signals`

If you just want to proxy the signals to a child process that the
main process receives, you can use the `proxy-signals` export
from this package.

```js
import { proxySignals } from 'foreground-child/proxy-signals'

const childProcess = spawn('command', ['some', 'args'])
proxySignals(childProcess)
```

Now, any fatal signal received by the current process will be
proxied to the child process.

It doesn't go in the other direction; ie, signals sent to the
child process will not affect the parent. For that, listen to the
child `exit` or `close` events, and handle them appropriately.

## util: `foreground-child/watchdog`

If you are spawning a child process, and want to ensure that it
isn't left dangling if the parent process exits, you can use the
watchdog utility exported by this module.

```js
import { watchdog } from 'foreground-child/watchdog'

const childProcess = spawn('command', ['some', 'args'])
const watchdogProcess = watchdog(childProcess)

// watchdogProcess is a reference to the process monitoring the
// parent and child. There's usually no reason to do anything
// with it, as it's silent and will terminate
// automatically when it's no longer needed.
```
Loading

0 comments on commit d0273cc

Please sign in to comment.