first-base 4.0.0 → 4.0.1
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 +23 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,8 @@ An object with the following properties on it:
|
|
|
34
34
|
- `code` (`number | null`): Exit status code, if the process has finished
|
|
35
35
|
- `error` (`null | Error`): If the process errored out, this is the Error
|
|
36
36
|
|
|
37
|
+
> NOTE: If spawned with option `pty: true`, `RunContext#result` has a single `output: string` property instead of both `stdout` and `stderr`.
|
|
38
|
+
|
|
37
39
|
This object gets updated over time as the process runs.
|
|
38
40
|
|
|
39
41
|
#### Usage
|
|
@@ -56,23 +58,6 @@ const run = spawn("ls", { cwd: __dirname });
|
|
|
56
58
|
await run.completion; // Waits until the `ls` process finishes
|
|
57
59
|
```
|
|
58
60
|
|
|
59
|
-
### `RunContext#debug() => RunContext`
|
|
60
|
-
|
|
61
|
-
Enables debug logging for the `RunContext` and returns it. Useful when your tests are failing and you want to understand what's going on.
|
|
62
|
-
|
|
63
|
-
Returns itself so you can add it to a variable declaration easily.
|
|
64
|
-
|
|
65
|
-
#### Usage
|
|
66
|
-
|
|
67
|
-
```js
|
|
68
|
-
const run = spawn("ls", { cwd: __dirname }).debug();
|
|
69
|
-
// The following messages are logged to the console over time:
|
|
70
|
-
//
|
|
71
|
-
// STDOUT: README.md\npackage.json\nindex.js
|
|
72
|
-
// Process exited
|
|
73
|
-
// { stdout: 'README.md\npackage.json\nindex.js', stderr: '', code: 0, error: null }
|
|
74
|
-
```
|
|
75
|
-
|
|
76
61
|
### `RunContext#outputContains(value: string | RegExp) => Promise<void>`
|
|
77
62
|
|
|
78
63
|
Returns a Promise that will resolve once the process's output (combined STDOUT/STDERR) contains either the specified string or matches the specified RegExp. Ignores ANSI control characters.
|
|
@@ -115,6 +100,8 @@ await run.outputContains("4");
|
|
|
115
100
|
|
|
116
101
|
Close one of the processes's associated stdio streams.
|
|
117
102
|
|
|
103
|
+
> NOTE: If spawned with option `pty: true`, `RunContext#close` is not present.
|
|
104
|
+
|
|
118
105
|
#### Usage
|
|
119
106
|
|
|
120
107
|
```js
|
|
@@ -134,12 +121,14 @@ Kills the process. If no signal is specified, it defaults to `"SIGINT"`.
|
|
|
134
121
|
const run = spawn("node", ["-i"]);
|
|
135
122
|
run.kill(); // Kill with SIGINT
|
|
136
123
|
// OR:
|
|
124
|
+
run.kill("SIGTERM"); // Kill with SIGTERM
|
|
137
125
|
run.kill("SIGKILL"); // Kill with SIGKILL
|
|
126
|
+
// etc
|
|
138
127
|
```
|
|
139
128
|
|
|
140
129
|
### `RunContext#cleanResult()`
|
|
141
130
|
|
|
142
|
-
A function which returns a new object with the same shape as `RunContext#result` but with its stdout/stderr passed through the `sanitizers` Array (see below).
|
|
131
|
+
A function which returns a new object with the same shape as `RunContext#result` but with its stdout/stderr/output passed through the `sanitizers` Array (see below).
|
|
143
132
|
|
|
144
133
|
Unlike `result`, this object does NOT get updated over time as the process runs.
|
|
145
134
|
|
|
@@ -174,7 +163,7 @@ It may be beneficial to clean these up in a test timeout handler or etc.
|
|
|
174
163
|
|
|
175
164
|
MIT
|
|
176
165
|
|
|
177
|
-
## Upgrading from 1.x
|
|
166
|
+
## Upgrading from 1.x to 2.x
|
|
178
167
|
|
|
179
168
|
The only things that changed between 1.x and 2.0 are:
|
|
180
169
|
|
|
@@ -184,7 +173,21 @@ The only things that changed between 1.x and 2.0 are:
|
|
|
184
173
|
- macOS arm64 and x86_64
|
|
185
174
|
- Windows arm64 and x86_64
|
|
186
175
|
|
|
187
|
-
## Upgrading from 2.x
|
|
176
|
+
## Upgrading from 2.x to 3.x
|
|
188
177
|
|
|
189
178
|
- The type definitions for `RunContext.write` and `RunContext.kill` were narrowed slightly. The runtime behavior of those methods didn't change.
|
|
190
179
|
- `RunContext.debug()` is deprecated (but not removed). Use `spawn` option `debug: true` instead.
|
|
180
|
+
|
|
181
|
+
## Upgrading from 3.x to 4.x
|
|
182
|
+
|
|
183
|
+
- `RunContext.debug()` is removed. Use `spawn` option `debug: true` instead.
|
|
184
|
+
- The RunContext.result of children spawned with option `pty: true` now has one `output: string` property instead of a fake `stdout: string` and always-empty `stderr: string`.
|
|
185
|
+
- In other words, stuff that was being written to `.stdout` is now written to `.output`. `stderr` was always empty for pty children because of how node-pty works.
|
|
186
|
+
- Non-pty children still have distinct `stdout` and `stderr` strings like always.
|
|
187
|
+
- For pty children, the "close" method which was a no-op on pty children has been removed.
|
|
188
|
+
- Non-pty children still have the "close" method.
|
|
189
|
+
- For non-pty children, RunContext.completion now doesn't resolve until both the "exit" AND "close" event have been fired.
|
|
190
|
+
- Previously it fired when the "close" event was fired, which was _usually_ after "exit".
|
|
191
|
+
- A pty child only has one distinct exit event, which is when its completion promise resolves. Same as before.
|
|
192
|
+
- For non-pty children, RunContext.completion now rejects when the "error" event is fired.
|
|
193
|
+
- Previously, RunContext.completion always resolved, even if RunContext.error was non-null.
|