Skip to content

Commit 3943d39

Browse files
Add shell and encoding options to exec (#29)
1 parent e16bcd2 commit 3943d39

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

CHANGELOG.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ Breaking changes:
88

99
New features:
1010

11+
- Added `shell` and `encoding` options to `exec` functions (#29 by @thomashoneyman)
12+
1113
Bugfixes:
1214

1315
Other improvements:
1416

1517
## [v7.0.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v7.0.0) - 2021-02-26
1618

1719
Breaking changes:
18-
- Updated dependencies for PureScript 0.14 (#25)
19-
20+
21+
- Updated dependencies for PureScript 0.14 (#25)
22+
2023
Other improvements:
21-
- Migrated CI to GitHub Actions and updated installation instructions to use Spago (#24)
22-
- Added a CHANGELOG.md file and pull request template (#26)
24+
25+
- Migrated CI to GitHub Actions and updated installation instructions to use Spago (#24)
26+
- Added a CHANGELOG.md file and pull request template (#26)
2327

2428
## [v6.0.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v6.0.0) - 2019-03-15
2529

@@ -83,8 +87,9 @@ Other improvements:
8387
## [v0.4.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v0.4.0) - 2015-12-29
8488

8589
- **Breaking change**:
90+
8691
- `SpawnOptions` now uses the `Uid` and `Gid` types from `purescript-posix-types` for its `uid` and `gid` options, instead of `Int`.
87-
92+
8893
- **New features**:
8994
- Added `exec`.
9095

src/Node/ChildProcess.purs

+8-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import Prelude
5353

5454
import Control.Alt ((<|>))
5555
import Data.Function.Uncurried (Fn2, runFn2)
56-
import Data.Maybe (Maybe(..), fromMaybe)
56+
import Data.Maybe (Maybe(..), fromMaybe, maybe)
5757
import Data.Nullable (Nullable, toNullable, toMaybe)
5858
import Data.Posix (Pid, Gid, Uid)
5959
import Data.Posix.Signal (Signal)
@@ -64,6 +64,7 @@ import Effect.Exception.Unsafe (unsafeThrow)
6464
import Foreign (Foreign)
6565
import Foreign.Object (Object)
6666
import Node.Buffer (Buffer)
67+
import Node.Encoding (Encoding, encodingToNode)
6768
import Node.FS as FS
6869
import Node.Stream (Readable, Writable, Stream)
6970
import Unsafe.Coerce (unsafeCoerce)
@@ -334,6 +335,8 @@ convertExecOptions :: ExecOptions -> ActualExecOptions
334335
convertExecOptions opts = unsafeCoerce
335336
{ cwd: fromMaybe undefined opts.cwd
336337
, env: fromMaybe undefined opts.env
338+
, encoding: maybe undefined encodingToNode opts.encoding
339+
, shell: fromMaybe undefined opts.shell
337340
, timeout: fromMaybe undefined opts.timeout
338341
, maxBuffer: fromMaybe undefined opts.maxBuffer
339342
, killSignal: fromMaybe undefined opts.killSignal
@@ -346,6 +349,8 @@ convertExecOptions opts = unsafeCoerce
346349
type ExecOptions =
347350
{ cwd :: Maybe String
348351
, env :: Maybe (Object String)
352+
, encoding :: Maybe Encoding
353+
, shell :: Maybe String
349354
, timeout :: Maybe Number
350355
, maxBuffer :: Maybe Int
351356
, killSignal :: Maybe Signal
@@ -358,6 +363,8 @@ defaultExecOptions :: ExecOptions
358363
defaultExecOptions =
359364
{ cwd: Nothing
360365
, env: Nothing
366+
, encoding: Nothing
367+
, shell: Nothing
361368
, timeout: Nothing
362369
, maxBuffer: Nothing
363370
, killSignal: Nothing

test/Main.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ main = do
2323

2424
log "doesn't perform effects too early"
2525
spawn "ls" ["-la"] defaultSpawnOptions >>= \ls -> do
26-
let unused = kill SIGTERM ls
26+
let _ = kill SIGTERM ls
2727
onExit ls \exit ->
2828
case exit of
2929
Normally 0 ->

0 commit comments

Comments
 (0)