Skip to content

Commit

Permalink
Fix another Kill signal type arg (#52)
Browse files Browse the repository at this point in the history
* Fix another Kill signal type arg

* Fix warning
  • Loading branch information
JordanMartinez authored Jul 25, 2023
1 parent 5e867de commit d9ad6d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ Other improvements:
## [v11.0.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v11.0.0) - 2023-07-25

Breaking changes:
- Update the signal arg from `String` to `KillSignal` (#51 by @JordanMartinez)
- Update the signal arg from `String` to `KillSignal` (#51, #52 by @JordanMartinez)

- `Exit`'s `BySignal` constructor's arg
- `exitH`/`closeH`'s signal arg
- `spawnSync`'s `SpawnResult`'s `signal` field
- `kill'`'s signal arg

New features:
- Added `fromKillSignal` (#51 by @JordanMartinez)
Expand Down
2 changes: 1 addition & 1 deletion src/Node/ChildProcess.purs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ disconnect = unsafeCoerce SafeCP.disconnect
kill :: ChildProcess -> Effect Boolean
kill = unsafeCoerce SafeCP.kill

kill' :: String -> ChildProcess -> Effect Boolean
kill' :: KillSignal -> ChildProcess -> Effect Boolean
kill' = unsafeCoerce SafeCP.kill'

-- | Send a signal to a child process. In the same way as the
Expand Down
8 changes: 4 additions & 4 deletions src/Node/UnsafeChildProcess/Safe.purs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Data.Posix.Signal as Signal
import Effect (Effect)
import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, mkEffectFn2, runEffectFn1, runEffectFn2)
import Foreign (Foreign)
import Node.ChildProcess.Types (Exit(..), Handle, KillSignal, StdIO, UnsafeChildProcess, ipc, pipe)
import Node.ChildProcess.Types (Exit(..), Handle, KillSignal, StdIO, UnsafeChildProcess, ipc, pipe, stringSignal)
import Node.Errors.SystemError (SystemError)
import Node.EventEmitter (EventEmitter, EventHandle(..))
import Node.EventEmitter.UtilTypes (EventHandle0, EventHandle1)
Expand Down Expand Up @@ -102,10 +102,10 @@ kill cp = runEffectFn1 killImpl cp

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

kill' :: String -> UnsafeChildProcess -> Effect Boolean
kill' :: KillSignal -> UnsafeChildProcess -> Effect Boolean
kill' sig cp = runEffectFn2 killStrImpl cp sig

foreign import killStrImpl :: EffectFn2 (UnsafeChildProcess) (String) (Boolean)
foreign import killStrImpl :: EffectFn2 (UnsafeChildProcess) (KillSignal) (Boolean)

-- | Send a signal to a child process. In the same way as the
-- | [unix kill(2) system call](https://linux.die.net/man/2/kill),
Expand All @@ -116,7 +116,7 @@ foreign import killStrImpl :: EffectFn2 (UnsafeChildProcess) (String) (Boolean)
-- | The child process might emit an `"error"` event if the signal
-- | could not be delivered.
killSignal :: Signal -> UnsafeChildProcess -> Effect Boolean
killSignal sig cp = kill' (Signal.toString sig) cp
killSignal sig cp = kill' (stringSignal $ Signal.toString sig) cp

killed :: UnsafeChildProcess -> Effect Boolean
killed cp = runEffectFn1 killedImpl cp
Expand Down

0 comments on commit d9ad6d0

Please sign in to comment.