Skip to content

Commit 6a4f27c

Browse files
Add unsafe API; reimplement CP via safe/unsafe API (#46)
* Add unsafe API * Move Handle into types * Move Unsafe to new namespace * Add Safe API; reimplement CP using it * Relocate send * Add Js prefix to all Js options * Rename execSyncOpts to execSync' * Reimplement ChildProcess bindings via Unsafe/Safe APIs * Update changelog * Update usage of exec' * Update FFI name to match PS one * Add missing docs on options * Add more missing options docs * Tweak docs one more time
1 parent dd7dd01 commit 6a4f27c

File tree

9 files changed

+1374
-416
lines changed

9 files changed

+1374
-416
lines changed

CHANGELOG.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,30 @@ Breaking changes:
2222
- Update `pid` type signature to return `Maybe Pid` rather than `Pid` (#44 by @JordanMartinez)
2323
- Update `kill` returned value from `Effect Unit` to `Effect Boolean` (#44 by @JordanMartinez)
2424
- Migrate `Error` to `node-os`' `SystemError` (#45 by @JordanMartinez)
25+
- Breaking changes made to the `Exit` type (#46 by @JordanMartinez)
2526

27+
- Moved from `Node.ChildProces` to `Node.ChildProces.Types`
28+
- Changed the `BySignal`'s constructor's arg type from `Signal` to `String`
29+
- Breaking changes made to the `Handle` type (#46 by @JordanMartinez)
30+
31+
- Moved from `Node.ChildProces` to `Node.ChildProces.Types`
32+
- Converted `defaultOptions { override = Just 1}` pattern to `(_ { override = Just 1})` (#46 by @JordanMartinez)
33+
34+
Before:
35+
```purs
36+
spawn "foo" [ "bar" ] (defaultSpawnOptions { someOption = Just overrideValue })
37+
spawn "foo" [ "bar" ] defaultSpawnOptions
38+
```
39+
40+
After:
41+
```purs
42+
spawn "foo" [ "bar" ] (_ { someOption = Just overrideValue })
43+
spawn "foo" [ "bar" ] identity
44+
```
45+
- Restrict end-user's ability to configure `stdio` to only those appended to `safeStdio` (#46 by @JordanMartinez)
46+
47+
See the module docs for `Node.ChildProcess`.
48+
- All `ChildProcess`-creating functions have been updated to support no args and all args variants (#46 by @JordanMartinez)
2649

2750
New features:
2851
- Added event handler for `spawn` event (#43 by @JordanMartinez)
@@ -36,14 +59,17 @@ New features:
3659
- signalCode
3760
- spawnArgs
3861
- spawnFile
62+
- Added unsafe, uncurried API of all ChildProcess-creating functions (#46 by @JordanMartinez)
63+
- Added safe variant of `spawnSync`/`spawnSync'` (#46 by @JordanMartinez)
3964

4065
Bugfixes:
4166

4267
Other improvements:
4368
- Bumped CI's node version to `lts/*` (#41 by @JordanMartinez)
4469
- Updated CI `actions/checkout` and `actions/setup-nodee` to `v3` (#41 by @JordanMartinez)
4570
- Format codebase & enforce formatting in CI via purs-tidy (#42 by @JordanMartinez)
46-
- Migrate more FFI to uncurried functions (#44 by @JordanMartinez)
71+
- Migrate FFI to uncurried functions (#44, #46 by @JordanMartinez)
72+
- Updated recommended module alias in docs (#46 by @JordanMartinez)
4773

4874
## [v9.0.0](https://github.com/purescript-node/purescript-node-child-process/releases/tag/v9.0.0) - 2022-04-29
4975

src/Node/ChildProcess.js

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,2 @@
1-
/* eslint-env node*/
2-
3-
import { spawn, exec, execFile, execSync, execFileSync, fork as cp_fork } from "child_process";
4-
5-
export function unsafeFromNullable(msg) {
6-
return x => {
7-
if (x === null) throw new Error(msg);
8-
return x;
9-
};
10-
}
11-
12-
export const connectedImpl = (cp) => cp.connected;
13-
export const disconnectImpl = (cp) => cp.disconnect();
14-
export const exitCodeImpl = (cp) => cp.exitCode;
15-
export const pidImpl = (cp) => cp.pid;
16-
export const killImpl = (cp) => cp.kill();
17-
export const killStrImpl = (cp, str) => cp.kill(str);
18-
export const killedImpl = (cp) => cp.killed;
19-
export const signalCodeImpl = (cp) => cp.signalCode;
20-
export const spawnArgs = (cp) => cp.spawnArgs;
21-
export const spawnFile = (cp) => cp.spawnFile;
22-
23-
export function spawnImpl(command) {
24-
return args => opts => () => spawn(command, args, opts);
25-
}
26-
27-
export function execImpl(command) {
28-
return opts => callback => () => exec(
29-
command,
30-
opts,
31-
(err, stdout, stderr) => {
32-
callback(err)(stdout)(stderr)();
33-
}
34-
);
35-
}
36-
37-
export const execFileImpl = function execImpl(command) {
38-
return args => opts => callback => () => execFile(
39-
command,
40-
args,
41-
opts,
42-
(err, stdout, stderr) => {
43-
callback(err)(stdout)(stderr)();
44-
}
45-
);
46-
};
47-
48-
export function execSyncImpl(command) {
49-
return opts => () => execSync(command, opts);
50-
}
51-
52-
export function execFileSyncImpl(command) {
53-
return args => opts => () => execFileSync(command, args, opts);
54-
}
55-
56-
export function fork(cmd) {
57-
return args => () => cp_fork(cmd, args);
58-
}
59-
601
const _undefined = undefined;
612
export { _undefined as undefined };
62-
import process from "process";
63-
export { process };

0 commit comments

Comments
 (0)