Skip to content

Add ref/unref #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Bugfixes:

Other improvements:

## [v10.1.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v10.1.0) - 2023-07-25

Other improvements:
- Fix regression: add `ref`/`unref` APIs that were dropped in `v10.0.0` (#50 by @JordanMartinez)

## [v10.0.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v10.0.0) - 2023-07-20

Breaking changes:
Expand Down
8 changes: 8 additions & 0 deletions src/Node/ChildProcess.purs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ module Node.ChildProcess
, kill'
, killSignal
, killed
, ref
, unref
, signalCode
, spawnFile
, spawnArgs
Expand Down Expand Up @@ -188,6 +190,12 @@ killSignal = unsafeCoerce SafeCP.killSignal
killed :: ChildProcess -> Effect Boolean
killed = unsafeCoerce SafeCP.killed

ref :: ChildProcess -> Effect Unit
ref = unsafeCoerce SafeCP.ref

unref :: ChildProcess -> Effect Unit
unref = unsafeCoerce SafeCP.unref

signalCode :: ChildProcess -> Effect (Maybe String)
signalCode = unsafeCoerce SafeCP.signalCode

Expand Down
2 changes: 2 additions & 0 deletions src/Node/UnsafeChildProcess/Safe.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const pidImpl = (cp) => cp.pid;
export const killImpl = (cp) => cp.kill();
export const killStrImpl = (cp, str) => cp.kill(str);
export const killedImpl = (cp) => cp.killed;
export const refImpl = (cp) => cp.ref();
export const unrefImpl = (cp) => cp.unref();
export const signalCodeImpl = (cp) => cp.signalCode;
export const spawnArgs = (cp) => cp.spawnArgs;
export const spawnFile = (cp) => cp.spawnFile;
13 changes: 13 additions & 0 deletions src/Node/UnsafeChildProcess/Safe.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ module Node.UnsafeChildProcess.Safe
, kill'
, killSignal
, killed
, ref
, unref
, signalCode
, spawnFile
, spawnArgs
, safeStdio

) where

import Prelude
Expand Down Expand Up @@ -120,6 +123,16 @@ killed cp = runEffectFn1 killedImpl cp

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

ref :: UnsafeChildProcess -> Effect Unit
ref cp = runEffectFn1 refImpl cp

foreign import refImpl :: EffectFn1 (UnsafeChildProcess) (Unit)

unref :: UnsafeChildProcess -> Effect Unit
unref cp = runEffectFn1 unrefImpl cp

foreign import unrefImpl :: EffectFn1 (UnsafeChildProcess) (Unit)

signalCode :: UnsafeChildProcess -> Effect (Maybe String)
signalCode cp = map toMaybe $ runEffectFn1 signalCodeImpl cp

Expand Down