Skip to content

Commit c3f8b99

Browse files
Add ref/unref (#50)
* Add ref/unref
1 parent 1c6b0c9 commit c3f8b99

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Bugfixes:
1212

1313
Other improvements:
1414

15+
## [v10.1.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v10.1.0) - 2023-07-25
16+
17+
Other improvements:
18+
- Fix regression: add `ref`/`unref` APIs that were dropped in `v10.0.0` (#50 by @JordanMartinez)
19+
1520
## [v10.0.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v10.0.0) - 2023-07-20
1621

1722
Breaking changes:

src/Node/ChildProcess.purs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ module Node.ChildProcess
5151
, kill'
5252
, killSignal
5353
, killed
54+
, ref
55+
, unref
5456
, signalCode
5557
, spawnFile
5658
, spawnArgs
@@ -188,6 +190,12 @@ killSignal = unsafeCoerce SafeCP.killSignal
188190
killed :: ChildProcess -> Effect Boolean
189191
killed = unsafeCoerce SafeCP.killed
190192

193+
ref :: ChildProcess -> Effect Unit
194+
ref = unsafeCoerce SafeCP.ref
195+
196+
unref :: ChildProcess -> Effect Unit
197+
unref = unsafeCoerce SafeCP.unref
198+
191199
signalCode :: ChildProcess -> Effect (Maybe String)
192200
signalCode = unsafeCoerce SafeCP.signalCode
193201

src/Node/UnsafeChildProcess/Safe.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export const pidImpl = (cp) => cp.pid;
55
export const killImpl = (cp) => cp.kill();
66
export const killStrImpl = (cp, str) => cp.kill(str);
77
export const killedImpl = (cp) => cp.killed;
8+
export const refImpl = (cp) => cp.ref();
9+
export const unrefImpl = (cp) => cp.unref();
810
export const signalCodeImpl = (cp) => cp.signalCode;
911
export const spawnArgs = (cp) => cp.spawnArgs;
1012
export const spawnFile = (cp) => cp.spawnFile;

src/Node/UnsafeChildProcess/Safe.purs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ module Node.UnsafeChildProcess.Safe
1717
, kill'
1818
, killSignal
1919
, killed
20+
, ref
21+
, unref
2022
, signalCode
2123
, spawnFile
2224
, spawnArgs
2325
, safeStdio
26+
2427
) where
2528

2629
import Prelude
@@ -120,6 +123,16 @@ killed cp = runEffectFn1 killedImpl cp
120123

121124
foreign import killedImpl :: EffectFn1 (UnsafeChildProcess) (Boolean)
122125

126+
ref :: UnsafeChildProcess -> Effect Unit
127+
ref cp = runEffectFn1 refImpl cp
128+
129+
foreign import refImpl :: EffectFn1 (UnsafeChildProcess) (Unit)
130+
131+
unref :: UnsafeChildProcess -> Effect Unit
132+
unref cp = runEffectFn1 unrefImpl cp
133+
134+
foreign import unrefImpl :: EffectFn1 (UnsafeChildProcess) (Unit)
135+
123136
signalCode :: UnsafeChildProcess -> Effect (Maybe String)
124137
signalCode cp = map toMaybe $ runEffectFn1 signalCodeImpl cp
125138

0 commit comments

Comments
 (0)