procband 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -3
- package/dist/index.d.mts +1 -9
- package/dist/index.mjs +2 -15
- package/docs/context.md +7 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,9 +29,6 @@ const result = await proc
|
|
|
29
29
|
console.log(result)
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
`stdin` is disabled by default. Set `stdin: true` to write to `proc.stdin`, or
|
|
33
|
-
pass a readable stream to `stdin` to pipe input automatically.
|
|
34
|
-
|
|
35
32
|
## Documentation Map
|
|
36
33
|
|
|
37
34
|
- Concepts and lifecycle: [docs/context.md](docs/context.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChildProcess } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import { Writable } from "node:stream";
|
|
3
3
|
|
|
4
4
|
//#region src/types.d.ts
|
|
5
5
|
/**
|
|
@@ -67,14 +67,6 @@ interface ProcessConfig {
|
|
|
67
67
|
* `process.stderr`.
|
|
68
68
|
*/
|
|
69
69
|
stderr?: Writable;
|
|
70
|
-
/**
|
|
71
|
-
* Child stdin behavior.
|
|
72
|
-
*
|
|
73
|
-
* Defaults to `false`, which connects the child stdin to the null device.
|
|
74
|
-
* Use `true` to expose a writable `proc.stdin`, or pass a readable stream to
|
|
75
|
-
* pipe bytes into the child automatically.
|
|
76
|
-
*/
|
|
77
|
-
stdin?: boolean | Readable;
|
|
78
70
|
/**
|
|
79
71
|
* Automatic restart behavior for terminal child exits.
|
|
80
72
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -516,7 +516,7 @@ var ProcbandProcessImpl = class extends EventEmitter {
|
|
|
516
516
|
cwd: this.config.cwd,
|
|
517
517
|
env: this.config.env,
|
|
518
518
|
stdio: [
|
|
519
|
-
|
|
519
|
+
"pipe",
|
|
520
520
|
"pipe",
|
|
521
521
|
"pipe"
|
|
522
522
|
]
|
|
@@ -537,15 +537,13 @@ var ProcbandProcessImpl = class extends EventEmitter {
|
|
|
537
537
|
text: "",
|
|
538
538
|
flushed: false
|
|
539
539
|
},
|
|
540
|
-
closed: false
|
|
541
|
-
stdinCleanup: null
|
|
540
|
+
closed: false
|
|
542
541
|
};
|
|
543
542
|
this.attempt = attempt;
|
|
544
543
|
this.attachAttempt(attempt);
|
|
545
544
|
}
|
|
546
545
|
attachAttempt(attempt) {
|
|
547
546
|
const { child } = attempt;
|
|
548
|
-
attempt.stdinCleanup = this.bindAttemptStdin(attempt);
|
|
549
547
|
child.on("spawn", () => {
|
|
550
548
|
if (this.attempt === attempt) this.emit("spawn");
|
|
551
549
|
});
|
|
@@ -558,8 +556,6 @@ var ProcbandProcessImpl = class extends EventEmitter {
|
|
|
558
556
|
child.on("close", (code, signal) => {
|
|
559
557
|
if (this.attempt !== attempt) return;
|
|
560
558
|
attempt.closed = true;
|
|
561
|
-
attempt.stdinCleanup?.();
|
|
562
|
-
attempt.stdinCleanup = null;
|
|
563
559
|
this.flushLineBuffer(attempt, "stdout");
|
|
564
560
|
this.flushLineBuffer(attempt, "stderr");
|
|
565
561
|
attempt.settleClose({
|
|
@@ -686,15 +682,6 @@ var ProcbandProcessImpl = class extends EventEmitter {
|
|
|
686
682
|
buffer.text = "";
|
|
687
683
|
this.handleLine(stream, line, false);
|
|
688
684
|
}
|
|
689
|
-
bindAttemptStdin(attempt) {
|
|
690
|
-
const source = this.config.stdin;
|
|
691
|
-
const destination = attempt.child.stdin;
|
|
692
|
-
if (!destination || typeof source !== "object") return null;
|
|
693
|
-
source.pipe(destination);
|
|
694
|
-
return () => {
|
|
695
|
-
source.unpipe(destination);
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
685
|
};
|
|
699
686
|
const liveProcesses = /* @__PURE__ */ new Set();
|
|
700
687
|
let propagatedFailure = false;
|
package/docs/context.md
CHANGED
|
@@ -35,8 +35,8 @@ Supervision adds four behaviors on top of raw `spawn()`:
|
|
|
35
35
|
# Core Abstractions
|
|
36
36
|
|
|
37
37
|
- `ProcessConfig`
|
|
38
|
-
Declares one supervised subprocess plus its label, color, restart policy,
|
|
39
|
-
optional
|
|
38
|
+
Declares one supervised subprocess plus its label, color, restart policy, and
|
|
39
|
+
optional raw `stderr` tee.
|
|
40
40
|
- `ProcbandProcess`
|
|
41
41
|
The live wrapper returned by `supervise()`. It is a `ChildProcess`-compatible
|
|
42
42
|
handle, a matching surface, a shutdown surface, and a thenable final result.
|
|
@@ -52,17 +52,14 @@ Supervision adds four behaviors on top of raw `spawn()`:
|
|
|
52
52
|
3. Each line is prefixed and written to the parent `process.stdout` or
|
|
53
53
|
`process.stderr`.
|
|
54
54
|
4. `stderr` can also be tee'd as raw bytes to `ProcessConfig.stderr`.
|
|
55
|
-
5.
|
|
56
|
-
a writable child stdin, or pass a readable stream to pipe input into the
|
|
57
|
-
child automatically.
|
|
58
|
-
6. Future matching lines are delivered through `match()` callbacks or
|
|
55
|
+
5. Future matching lines are delivered through `match()` callbacks or
|
|
59
56
|
`waitFor()`.
|
|
60
|
-
|
|
57
|
+
6. When a child exits, `procband` either finalizes or starts a new attempt,
|
|
61
58
|
depending on the restart policy.
|
|
62
|
-
|
|
59
|
+
7. A terminal failed exit that nobody observed through `await proc` or
|
|
63
60
|
`proc.wait()` sets `process.exitCode` and begins
|
|
64
61
|
stopping any other live `procband` processes in the same parent script.
|
|
65
|
-
|
|
62
|
+
8. `await proc` or `await proc.wait()` resolves only after the process is
|
|
66
63
|
terminal and no further restart will happen.
|
|
67
64
|
|
|
68
65
|
# Common Tasks -> Recommended APIs
|
|
@@ -81,10 +78,6 @@ Supervision adds four behaviors on top of raw `spawn()`:
|
|
|
81
78
|
Do not call `wait()` or await the thenable result
|
|
82
79
|
- Capture raw child `stderr` in a file or custom stream:
|
|
83
80
|
`ProcessConfig.stderr`
|
|
84
|
-
- Write to child stdin manually:
|
|
85
|
-
`stdin: true`, then `proc.stdin?.write(...)`
|
|
86
|
-
- Pipe a custom input stream into the child:
|
|
87
|
-
`stdin: readable`
|
|
88
81
|
- Retry failed exits with sane defaults:
|
|
89
82
|
`restart: true`
|
|
90
83
|
- Use explicit retry rules:
|
|
@@ -109,7 +102,7 @@ Supervision adds four behaviors on top of raw `spawn()`:
|
|
|
109
102
|
processes in the same parent script.
|
|
110
103
|
- The wrapper survives restarts, but inherited `pid`, `stdin`, `stdout`,
|
|
111
104
|
`stderr`, and related `ChildProcess` fields always refer to the current active
|
|
112
|
-
child attempt.
|
|
105
|
+
child attempt.
|
|
113
106
|
- `kill()` only signals the current direct child. `stop()` disables restart and
|
|
114
107
|
kills the full process tree.
|
|
115
108
|
- Parent cleanup installs both `SIGINT` and `SIGTERM` handlers while any live
|
package/package.json
CHANGED