first-base 0.2.0 → 1.3.0
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 +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.flow +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -111,6 +111,19 @@ run.write("2 + 2\n"); // Write 2 + 2 then press enter
|
|
|
111
111
|
await run.outputContains("4");
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
### `RunContext#close(stream: 'stdin' | 'stdout' | 'stderr')`
|
|
115
|
+
|
|
116
|
+
Close one of the processes's associated stdio streams.
|
|
117
|
+
|
|
118
|
+
#### Usage
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
const run = spawn("node", ["-i"]); // start Node.js REPL
|
|
122
|
+
await run.outputContains("> "); // Wait until prompt appears
|
|
123
|
+
run.close("stdin"); // Like pressing Ctrl+D; sends EOF
|
|
124
|
+
await run.completion;
|
|
125
|
+
```
|
|
126
|
+
|
|
114
127
|
### `RunContext#kill(signal?: string)`
|
|
115
128
|
|
|
116
129
|
Kills the process. If no signal is specified, it defaults to `"SIGINT"`.
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export type RunContext = {
|
|
|
23
23
|
clearOutputContainsBuffer(): void;
|
|
24
24
|
// TODO: Should be string | Buffer, but idk how to use Buffer since they might not be using node types
|
|
25
25
|
write(data: any): void;
|
|
26
|
+
close(stream: "stdin" | "stdout" | "stderr"): void;
|
|
26
27
|
kill(signal?: string): void;
|
|
27
28
|
};
|
|
28
29
|
|
package/dist/index.js
CHANGED
|
@@ -96,6 +96,33 @@ var spawn = function spawn(cmd, argsOrOptions, passedOptions) {
|
|
|
96
96
|
write: function write(data) {
|
|
97
97
|
stdin.write(data);
|
|
98
98
|
},
|
|
99
|
+
// Call this function to close stdin, stdout, or stderr.
|
|
100
|
+
close: function close(stream) {
|
|
101
|
+
switch (String(stream).toLowerCase()) {
|
|
102
|
+
case "stdin":
|
|
103
|
+
{
|
|
104
|
+
stdin.end();
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
case "stdout":
|
|
109
|
+
{
|
|
110
|
+
stdout.end();
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
case "stderr":
|
|
115
|
+
{
|
|
116
|
+
stderr.end();
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
default:
|
|
121
|
+
{
|
|
122
|
+
throw new Error("Invalid stream name: '".concat(stream, "'. Valid names are 'stdin', 'stdout', or 'stderr'."));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
99
126
|
// Call this function to send a signal to the child process.
|
|
100
127
|
// You can pass "SIGTERM", "SIGKILL", etc. Defaults to "SIGINT".
|
|
101
128
|
kill: function kill() {
|
package/dist/index.js.flow
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "first-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Integration testing for CLI applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": "https://github.com/suchipi/first-base",
|
|
7
|
-
"author": "Lily
|
|
7
|
+
"author": "Lily Skye <me@suchipi.com>",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"strip-ansi": "^5.0.0"
|