Skip to content

Commit d0273cc

Browse files
authored
Merge branch 'main' into feat/watchdog-info
2 parents b272753 + 132a017 commit d0273cc

30 files changed

+4153
-3673
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build:
77
strategy:
88
matrix:
9-
node-version: [14.x, 16.x, 18.x, 19.x]
9+
node-version: [18.x, 20.x, 22.x]
1010
platform:
1111
- os: ubuntu-latest
1212
shell: bash

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/node_modules
2+
/.tap
23
.DS_Store
3-
/coverage
44
/dist
5+
/node_modules

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/node_modules
2+
/.tshy
23
/example
34
/.github
45
/dist
@@ -7,3 +8,6 @@
78
/.nyc_output
89
/coverage
910
/benchmark
11+
/test/fixtures/*.d.ts
12+
/test/fixtures/*.js
13+
/test/fixtures/*.map

.tshy/build.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "../src",
5+
"module": "nodenext",
6+
"moduleResolution": "nodenext"
7+
}
8+
}

.tshy/commonjs.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./build.json",
3+
"include": [
4+
"../src/**/*.ts",
5+
"../src/**/*.cts",
6+
"../src/**/*.tsx"
7+
],
8+
"exclude": [
9+
"../src/**/*.mts"
10+
],
11+
"compilerOptions": {
12+
"outDir": "../.tshy-build/commonjs"
13+
}
14+
}

.tshy/esm.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./build.json",
3+
"include": [
4+
"../src/**/*.ts",
5+
"../src/**/*.mts",
6+
"../src/**/*.tsx"
7+
],
8+
"exclude": [],
9+
"compilerOptions": {
10+
"outDir": "../.tshy-build/esm"
11+
}
12+
}

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## v3.2
4+
5+
- Export `watchdog` and `proxySignals` functionality
6+
37
## v3.1
48

59
- Add support for optional SpawnOptions param

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,41 @@ status code rather than reporting the signal properly. This
8888
module tries to do the right thing, but on Windows systems, you
8989
may see that incorrect result. There is as far as I'm aware no
9090
workaround for this.
91+
92+
## util: `foreground-child/proxy-signals`
93+
94+
If you just want to proxy the signals to a child process that the
95+
main process receives, you can use the `proxy-signals` export
96+
from this package.
97+
98+
```js
99+
import { proxySignals } from 'foreground-child/proxy-signals'
100+
101+
const childProcess = spawn('command', ['some', 'args'])
102+
proxySignals(childProcess)
103+
```
104+
105+
Now, any fatal signal received by the current process will be
106+
proxied to the child process.
107+
108+
It doesn't go in the other direction; ie, signals sent to the
109+
child process will not affect the parent. For that, listen to the
110+
child `exit` or `close` events, and handle them appropriately.
111+
112+
## util: `foreground-child/watchdog`
113+
114+
If you are spawning a child process, and want to ensure that it
115+
isn't left dangling if the parent process exits, you can use the
116+
watchdog utility exported by this module.
117+
118+
```js
119+
import { watchdog } from 'foreground-child/watchdog'
120+
121+
const childProcess = spawn('command', ['some', 'args'])
122+
const watchdogProcess = watchdog(childProcess)
123+
124+
// watchdogProcess is a reference to the process monitoring the
125+
// parent and child. There's usually no reason to do anything
126+
// with it, as it's silent and will terminate
127+
// automatically when it's no longer needed.
128+
```

0 commit comments

Comments
 (0)