dollar-shell 1.0.5 → 1.1.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 +1 -0
- package/package.json +2 -2
- package/src/index.d.ts +19 -14
- package/src/index.js +2 -2
- package/src/spawn/bun.js +4 -0
- package/src/spawn/deno.js +4 -0
- package/src/spawn/node.js +4 -0
package/README.md
CHANGED
|
@@ -204,6 +204,7 @@ BSD-3-Clause
|
|
|
204
204
|
|
|
205
205
|
## Release History
|
|
206
206
|
|
|
207
|
+
* 1.1.0 *Added `asDuplex` to the sub-process object.*
|
|
207
208
|
* 1.0.5 *Updated dev dependencies.*
|
|
208
209
|
* 1.0.4 *Fixed `raw()` for spawn commands.*
|
|
209
210
|
* 1.0.3 *Added TSDoc comments, improved docs, fixed typos, added the missing copying of properties.*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dollar-shell",
|
|
3
3
|
"description": "Run shell commands and use them in streams with ease in Node, Deno, Bun. Tiny, simple, no dependency package.",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./src/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"license": "BSD-3-Clause",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"tape-six": "^0.12.
|
|
49
|
+
"tape-six": "^0.12.2",
|
|
50
50
|
"typescript": "^5.6.2"
|
|
51
51
|
},
|
|
52
52
|
"tape6": {
|
package/src/index.d.ts
CHANGED
|
@@ -29,6 +29,20 @@ export interface SpawnOptions {
|
|
|
29
29
|
stderr?: SpawnStreamState;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Object with readable and writable streams. It can be used as a duplex stream.
|
|
34
|
+
*/
|
|
35
|
+
interface DuplexPair<R = any> {
|
|
36
|
+
/**
|
|
37
|
+
* The readable stream.
|
|
38
|
+
*/
|
|
39
|
+
readable: ReadableStream<R>;
|
|
40
|
+
/**
|
|
41
|
+
* The writable stream.
|
|
42
|
+
*/
|
|
43
|
+
writable: WritableStream<R>;
|
|
44
|
+
}
|
|
45
|
+
|
|
32
46
|
/**
|
|
33
47
|
* Sub-process object.
|
|
34
48
|
*/
|
|
@@ -77,6 +91,11 @@ export interface Subprocess<R = any> {
|
|
|
77
91
|
* It is `null` if `options.stderr` was not set to `'pipe'`.
|
|
78
92
|
*/
|
|
79
93
|
readonly stderr: ReadableStream<R> | null;
|
|
94
|
+
/**
|
|
95
|
+
* Returns a duplex stream that can be used to pipe the input and output.
|
|
96
|
+
* It is defined as `{readable: this.stdout, writable: this.stdin}`.
|
|
97
|
+
*/
|
|
98
|
+
readonly asDuplex: DuplexPair<R>;
|
|
80
99
|
/**
|
|
81
100
|
* Kill the process.
|
|
82
101
|
*/
|
|
@@ -181,20 +200,6 @@ export interface DollarResult {
|
|
|
181
200
|
killed: boolean;
|
|
182
201
|
}
|
|
183
202
|
|
|
184
|
-
/**
|
|
185
|
-
* Object with readable and writable streams. It can be used as a duplex stream.
|
|
186
|
-
*/
|
|
187
|
-
interface DuplexPair<R = any> {
|
|
188
|
-
/**
|
|
189
|
-
* The readable stream.
|
|
190
|
-
*/
|
|
191
|
-
readable: ReadableStream<R>;
|
|
192
|
-
/**
|
|
193
|
-
* The writable stream.
|
|
194
|
-
*/
|
|
195
|
-
writable: WritableStream<R>;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
203
|
/**
|
|
199
204
|
* The type of the {@link $} function.
|
|
200
205
|
*/
|
package/src/index.js
CHANGED
|
@@ -50,7 +50,7 @@ const toProcess = bqSpawn((command, options) => {
|
|
|
50
50
|
|
|
51
51
|
const throughProcess = bqSpawn((command, options) => {
|
|
52
52
|
const sp = spawn(command, Object.assign({}, options, {stdin: 'pipe', stdout: 'pipe'}));
|
|
53
|
-
return
|
|
53
|
+
return sp.asDuplex;
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
$.from = fromProcess;
|
|
@@ -79,7 +79,7 @@ const toShell = bqShell(shellEscape, (command, options) => {
|
|
|
79
79
|
|
|
80
80
|
const throughShell = bqShell(shellEscape, (command, options) => {
|
|
81
81
|
const sp = spawn(buildShellCommand(options?.shellPath, options?.shellArgs, command), Object.assign({}, options, {stdin: 'pipe', stdout: 'pipe'}));
|
|
82
|
-
return
|
|
82
|
+
return sp.asDuplex;
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
$sh.from = fromShell;
|
package/src/spawn/bun.js
CHANGED
package/src/spawn/deno.js
CHANGED
|
@@ -63,6 +63,10 @@ class Subprocess {
|
|
|
63
63
|
return this.spawnOptions.stderr === 'piped' ? this.childProcess.stderr : null;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
get asDuplex() {
|
|
67
|
+
return {readable: this.stdout, writable: this.stdin};
|
|
68
|
+
}
|
|
69
|
+
|
|
66
70
|
kill() {
|
|
67
71
|
this.killed = true;
|
|
68
72
|
this.controller.abort();
|
package/src/spawn/node.js
CHANGED
|
@@ -61,6 +61,10 @@ class Subprocess {
|
|
|
61
61
|
this.stderr = this.childProcess.stderr && Readable.toWeb(this.childProcess.stderr);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
get asDuplex() {
|
|
65
|
+
return {readable: this.stdout, writable: this.stdin};
|
|
66
|
+
}
|
|
67
|
+
|
|
64
68
|
kill() {
|
|
65
69
|
this.killed = true;
|
|
66
70
|
this.childProcess.kill();
|