From 258e3a967b9a35354599b840baabf6bd9c7c9401 Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Tue, 25 Jul 2023 16:43:31 -0700 Subject: [PATCH] Add stdio (#56) * Add stdio --- CHANGELOG.md | 1 + src/Node/ChildProcess.purs | 4 ++++ src/Node/UnsafeChildProcess/Safe.js | 1 + src/Node/UnsafeChildProcess/Safe.purs | 4 +++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f94dee..ac2a02c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ New features: - Added `fromKillSignal` (#51 by @JordanMartinez) - Added `pidExists` (#53 by @JordanMartinez) - Export `toUnsafeChildProcess` (#54 by @JordanMartinez) +- Added `stdio` (#55 by @JordanMartinez) Other improvements: - Fix regression: add `ref`/`unref` APIs that were dropped in `v10.0.0` (#50 by @JordanMartinez) diff --git a/src/Node/ChildProcess.purs b/src/Node/ChildProcess.purs index f5618ca..6dc6017 100644 --- a/src/Node/ChildProcess.purs +++ b/src/Node/ChildProcess.purs @@ -58,6 +58,7 @@ module Node.ChildProcess , signalCode , spawnFile , spawnArgs + , stdio , spawnSync , SpawnSyncOptions , spawnSync' @@ -210,6 +211,9 @@ spawnArgs cp = SafeCP.spawnArgs $ toUnsafeChildProcess cp spawnFile :: ChildProcess -> String spawnFile cp = SafeCP.spawnFile $ toUnsafeChildProcess cp +stdio :: ChildProcess -> Array StdIO +stdio cp = SafeCP.stdio $ toUnsafeChildProcess cp + -- | Note: `exitStatus` combines the `status` and `signal` fields -- | from the value normally returned by `spawnSync` into one value -- | since only one of them can be non-null at the end. diff --git a/src/Node/UnsafeChildProcess/Safe.js b/src/Node/UnsafeChildProcess/Safe.js index e2c744a..cba3fda 100644 --- a/src/Node/UnsafeChildProcess/Safe.js +++ b/src/Node/UnsafeChildProcess/Safe.js @@ -10,3 +10,4 @@ export const unrefImpl = (cp) => cp.unref(); export const signalCodeImpl = (cp) => cp.signalCode; export const spawnArgs = (cp) => cp.spawnArgs; export const spawnFile = (cp) => cp.spawnFile; +export const stdio = (cp) => cp.stdio; diff --git a/src/Node/UnsafeChildProcess/Safe.purs b/src/Node/UnsafeChildProcess/Safe.purs index 541462e..9fc9b22 100644 --- a/src/Node/UnsafeChildProcess/Safe.purs +++ b/src/Node/UnsafeChildProcess/Safe.purs @@ -23,8 +23,8 @@ module Node.UnsafeChildProcess.Safe , signalCode , spawnFile , spawnArgs + , stdio , safeStdio - ) where import Prelude @@ -148,6 +148,8 @@ foreign import spawnArgs :: UnsafeChildProcess -> Array String foreign import spawnFile :: UnsafeChildProcess -> String +foreign import stdio :: UnsafeChildProcess -> Array StdIO + -- | Safe default configuration for an UnsafeChildProcess. -- | `[ pipe, pipe, pipe, ipc ]`. -- | Creates a new stream for `stdin`, `stdout`, and `stderr`