spawn-rx 4.0.0-beta.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CODE_OF_CONDUCT.md +119 -36
- package/COPYING +1 -1
- package/lib/src/index.d.ts +104 -16
- package/lib/src/index.js +59 -31
- package/lib/src/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +267 -73
- package/test/spawn.ts +14 -0
package/CODE_OF_CONDUCT.md
CHANGED
@@ -1,50 +1,133 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
1
|
|
3
|
-
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
2
|
+
# Contributor Covenant Code of Conduct
|
7
3
|
|
8
|
-
|
9
|
-
experience for everyone, regardless of level of experience, gender, gender
|
10
|
-
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
-
body size, race, ethnicity, age, religion, or nationality.
|
4
|
+
## Our Pledge
|
12
5
|
|
13
|
-
|
6
|
+
We as members, contributors, and leaders pledge to make participation in our
|
7
|
+
community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
9
|
+
identity and expression, level of experience, education, socio-economic status,
|
10
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
11
|
+
identity and orientation.
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
14
|
+
diverse, inclusive, and healthy community.
|
15
|
+
|
16
|
+
## Our Standards
|
17
|
+
|
18
|
+
Examples of behavior that contributes to a positive environment for our
|
19
|
+
community include:
|
20
|
+
|
21
|
+
* Demonstrating empathy and kindness toward other people
|
22
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
23
|
+
* Giving and gracefully accepting constructive feedback
|
24
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
25
|
+
and learning from the experience
|
26
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
27
|
+
community
|
28
|
+
|
29
|
+
Examples of unacceptable behavior include:
|
30
|
+
|
31
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
32
|
+
any kind
|
33
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
18
34
|
* Public or private harassment
|
19
|
-
* Publishing
|
20
|
-
|
21
|
-
* Other
|
35
|
+
* Publishing others' private information, such as a physical or email address,
|
36
|
+
without their explicit permission
|
37
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
38
|
+
professional setting
|
39
|
+
|
40
|
+
## Enforcement Responsibilities
|
41
|
+
|
42
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
43
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
44
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
45
|
+
or harmful.
|
22
46
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
threatening, offensive, or harmful.
|
47
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
48
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
49
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
50
|
+
decisions when appropriate.
|
28
51
|
|
29
|
-
|
30
|
-
fairly and consistently applying these principles to every aspect of managing
|
31
|
-
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
-
Conduct may be permanently removed from the project team.
|
52
|
+
## Scope
|
33
53
|
|
34
|
-
This Code of Conduct applies
|
35
|
-
|
54
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
55
|
+
an individual is officially representing the community in public spaces.
|
56
|
+
Examples of representing our community include using an official email address,
|
57
|
+
posting via an official social media account, or acting as an appointed
|
58
|
+
representative at an online or offline event.
|
59
|
+
|
60
|
+
## Enforcement
|
36
61
|
|
37
62
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
-
reported
|
39
|
-
complaints will be reviewed and investigated
|
40
|
-
|
41
|
-
|
42
|
-
|
63
|
+
reported to the community leaders responsible for enforcement at
|
64
|
+
anais@anaisbetts.org. All complaints will be reviewed and investigated promptly
|
65
|
+
and fairly.
|
66
|
+
|
67
|
+
All community leaders are obligated to respect the privacy and security of the
|
68
|
+
reporter of any incident.
|
69
|
+
|
70
|
+
## Enforcement Guidelines
|
71
|
+
|
72
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
73
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
74
|
+
|
75
|
+
### 1. Correction
|
76
|
+
|
77
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
78
|
+
unprofessional or unwelcome in the community.
|
43
79
|
|
80
|
+
**Consequence**: A private, written warning from community leaders, providing
|
81
|
+
clarity around the nature of the violation and an explanation of why the
|
82
|
+
behavior was inappropriate. A public apology may be requested.
|
83
|
+
|
84
|
+
### 2. Warning
|
85
|
+
|
86
|
+
**Community Impact**: A violation through a single incident or series of
|
87
|
+
actions.
|
88
|
+
|
89
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
90
|
+
interaction with the people involved, including unsolicited interaction with
|
91
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
92
|
+
includes avoiding interactions in community spaces as well as external channels
|
93
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
94
|
+
ban.
|
95
|
+
|
96
|
+
### 3. Temporary Ban
|
97
|
+
|
98
|
+
**Community Impact**: A serious violation of community standards, including
|
99
|
+
sustained inappropriate behavior.
|
100
|
+
|
101
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
102
|
+
communication with the community for a specified period of time. No public or
|
103
|
+
private interaction with the people involved, including unsolicited interaction
|
104
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
105
|
+
Violating these terms may lead to a permanent ban.
|
106
|
+
|
107
|
+
### 4. Permanent Ban
|
108
|
+
|
109
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
110
|
+
standards, including sustained inappropriate behavior, harassment of an
|
111
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
112
|
+
|
113
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
114
|
+
community.
|
115
|
+
|
116
|
+
## Attribution
|
44
117
|
|
45
118
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
46
|
-
version 1
|
47
|
-
[
|
119
|
+
version 2.1, available at
|
120
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
121
|
+
|
122
|
+
Community Impact Guidelines were inspired by
|
123
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
124
|
+
|
125
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
126
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
127
|
+
[https://www.contributor-covenant.org/translations][translations].
|
48
128
|
|
49
|
-
[homepage]:
|
50
|
-
[
|
129
|
+
[homepage]: https://www.contributor-covenant.org
|
130
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
131
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
132
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
133
|
+
[translations]: https://www.contributor-covenant.org/translations
|
package/COPYING
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2016
|
1
|
+
Copyright (c) 2016 Anaïs Betts
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
4
|
|
package/lib/src/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Observable } from "rxjs";
|
2
|
+
import { SpawnOptions } from "child_process";
|
2
3
|
/**
|
3
4
|
* Finds the actual executable and parameters to run on Windows. This method
|
4
5
|
* mimics the POSIX behavior of being able to run scripts as executables by
|
@@ -9,15 +10,25 @@ import { Observable } from "rxjs";
|
|
9
10
|
* also doesn't do, unlike on POSIX.
|
10
11
|
*
|
11
12
|
* @param {string} exe The executable to run
|
12
|
-
* @param {
|
13
|
+
* @param {string[]} args The arguments to run
|
13
14
|
*
|
14
15
|
* @return {Object} The cmd and args to run
|
15
16
|
* @property {string} cmd The command to pass to spawn
|
16
|
-
* @property {
|
17
|
+
* @property {string[]} args The arguments to pass to spawn
|
17
18
|
*/
|
18
|
-
export declare function findActualExecutable(exe: string, args:
|
19
|
+
export declare function findActualExecutable(exe: string, args: string[]): {
|
19
20
|
cmd: string;
|
20
|
-
args:
|
21
|
+
args: string[];
|
22
|
+
};
|
23
|
+
export type SpawnRxExtras = {
|
24
|
+
stdin?: Observable<string>;
|
25
|
+
split?: boolean;
|
26
|
+
jobber?: boolean;
|
27
|
+
encoding?: BufferEncoding;
|
28
|
+
};
|
29
|
+
export type OutputLine = {
|
30
|
+
source: "stdout" | "stderr";
|
31
|
+
text: string;
|
21
32
|
};
|
22
33
|
/**
|
23
34
|
* Spawns a process but detached from the current process. The process is put
|
@@ -25,8 +36,28 @@ export declare function findActualExecutable(exe: string, args: Array<string>):
|
|
25
36
|
* return Observable.
|
26
37
|
*
|
27
38
|
* @param {string} exe The executable to run
|
28
|
-
* @param {
|
29
|
-
* @param {
|
39
|
+
* @param {string[]} params The parameters to pass to the child
|
40
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
41
|
+
*
|
42
|
+
* @return {Observable<OutputLine>} Returns an Observable that when subscribed
|
43
|
+
* to, will create a detached process. The
|
44
|
+
* process output will be streamed to this
|
45
|
+
* Observable, and if unsubscribed from, the
|
46
|
+
* process will be terminated early. If the
|
47
|
+
* process terminates with a non-zero value,
|
48
|
+
* the Observable will terminate with onError.
|
49
|
+
*/
|
50
|
+
export declare function spawnDetached(exe: string, params: string[], opts: SpawnOptions & SpawnRxExtras & {
|
51
|
+
split: true;
|
52
|
+
}): Observable<OutputLine>;
|
53
|
+
/**
|
54
|
+
* Spawns a process but detached from the current process. The process is put
|
55
|
+
* into its own Process Group that can be killed by unsubscribing from the
|
56
|
+
* return Observable.
|
57
|
+
*
|
58
|
+
* @param {string} exe The executable to run
|
59
|
+
* @param {string[]} params The parameters to pass to the child
|
60
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
30
61
|
*
|
31
62
|
* @return {Observable<string>} Returns an Observable that when subscribed
|
32
63
|
* to, will create a detached process. The
|
@@ -36,13 +67,33 @@ export declare function findActualExecutable(exe: string, args: Array<string>):
|
|
36
67
|
* process terminates with a non-zero value,
|
37
68
|
* the Observable will terminate with onError.
|
38
69
|
*/
|
39
|
-
export declare function spawnDetached(exe: string, params:
|
70
|
+
export declare function spawnDetached(exe: string, params: string[], opts?: SpawnOptions & SpawnRxExtras & {
|
71
|
+
split: false | undefined;
|
72
|
+
}): Observable<string>;
|
40
73
|
/**
|
41
74
|
* Spawns a process attached as a child of the current process.
|
42
75
|
*
|
43
76
|
* @param {string} exe The executable to run
|
44
|
-
* @param {
|
45
|
-
* @param {
|
77
|
+
* @param {string[]} params The parameters to pass to the child
|
78
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
79
|
+
*
|
80
|
+
* @return {Observable<OutputLine>} Returns an Observable that when subscribed
|
81
|
+
* to, will create a child process. The
|
82
|
+
* process output will be streamed to this
|
83
|
+
* Observable, and if unsubscribed from, the
|
84
|
+
* process will be terminated early. If the
|
85
|
+
* process terminates with a non-zero value,
|
86
|
+
* the Observable will terminate with onError.
|
87
|
+
*/
|
88
|
+
export declare function spawn(exe: string, params: string[], opts: SpawnOptions & SpawnRxExtras & {
|
89
|
+
split: true;
|
90
|
+
}): Observable<OutputLine>;
|
91
|
+
/**
|
92
|
+
* Spawns a process attached as a child of the current process.
|
93
|
+
*
|
94
|
+
* @param {string} exe The executable to run
|
95
|
+
* @param {string[]} params The parameters to pass to the child
|
96
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
46
97
|
*
|
47
98
|
* @return {Observable<string>} Returns an Observable that when subscribed
|
48
99
|
* to, will create a child process. The
|
@@ -52,14 +103,33 @@ export declare function spawnDetached(exe: string, params: Array<string>, opts?:
|
|
52
103
|
* process terminates with a non-zero value,
|
53
104
|
* the Observable will terminate with onError.
|
54
105
|
*/
|
55
|
-
export declare function spawn
|
106
|
+
export declare function spawn(exe: string, params: string[], opts?: SpawnOptions & SpawnRxExtras & {
|
107
|
+
split: false | undefined;
|
108
|
+
}): Observable<string>;
|
109
|
+
/**
|
110
|
+
* Spawns a process but detached from the current process. The process is put
|
111
|
+
* into its own Process Group.
|
112
|
+
*
|
113
|
+
* @param {string} exe The executable to run
|
114
|
+
* @param {string[]} params The parameters to pass to the child
|
115
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
116
|
+
*
|
117
|
+
* @return {Promise<[string, string]>} Returns an Promise that represents a detached
|
118
|
+
* process. The value returned is the process
|
119
|
+
* output. If the process terminates with a
|
120
|
+
* non-zero value, the Promise will resolve with
|
121
|
+
* an Error.
|
122
|
+
*/
|
123
|
+
export declare function spawnDetachedPromise(exe: string, params: string[], opts: SpawnOptions & SpawnRxExtras & {
|
124
|
+
split: true;
|
125
|
+
}): Promise<[string, string]>;
|
56
126
|
/**
|
57
127
|
* Spawns a process but detached from the current process. The process is put
|
58
128
|
* into its own Process Group.
|
59
129
|
*
|
60
130
|
* @param {string} exe The executable to run
|
61
|
-
* @param {
|
62
|
-
* @param {
|
131
|
+
* @param {string[]} params The parameters to pass to the child
|
132
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
63
133
|
*
|
64
134
|
* @return {Promise<string>} Returns an Promise that represents a detached
|
65
135
|
* process. The value returned is the process
|
@@ -67,13 +137,31 @@ export declare function spawn<T = string>(exe: string, params?: Array<string>, o
|
|
67
137
|
* non-zero value, the Promise will resolve with
|
68
138
|
* an Error.
|
69
139
|
*/
|
70
|
-
export declare function spawnDetachedPromise(exe: string, params:
|
140
|
+
export declare function spawnDetachedPromise(exe: string, params: string[], opts?: SpawnOptions & SpawnRxExtras & {
|
141
|
+
split: false | undefined;
|
142
|
+
}): Promise<string>;
|
143
|
+
/**
|
144
|
+
* Spawns a process as a child process.
|
145
|
+
*
|
146
|
+
* @param {string} exe The executable to run
|
147
|
+
* @param {string[]} params The parameters to pass to the child
|
148
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
149
|
+
*
|
150
|
+
* @return {Promise<[string, string]>} Returns an Promise that represents a child
|
151
|
+
* process. The value returned is the process
|
152
|
+
* output. If the process terminates with a
|
153
|
+
* non-zero value, the Promise will resolve with
|
154
|
+
* an Error.
|
155
|
+
*/
|
156
|
+
export declare function spawnPromise(exe: string, params: string[], opts: SpawnOptions & SpawnRxExtras & {
|
157
|
+
split: true;
|
158
|
+
}): Promise<[string, string]>;
|
71
159
|
/**
|
72
160
|
* Spawns a process as a child process.
|
73
161
|
*
|
74
162
|
* @param {string} exe The executable to run
|
75
|
-
* @param {
|
76
|
-
* @param {
|
163
|
+
* @param {string[]} params The parameters to pass to the child
|
164
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
77
165
|
*
|
78
166
|
* @return {Promise<string>} Returns an Promise that represents a child
|
79
167
|
* process. The value returned is the process
|
@@ -81,4 +169,4 @@ export declare function spawnDetachedPromise(exe: string, params: Array<string>,
|
|
81
169
|
* non-zero value, the Promise will resolve with
|
82
170
|
* an Error.
|
83
171
|
*/
|
84
|
-
export declare function spawnPromise(exe: string, params:
|
172
|
+
export declare function spawnPromise(exe: string, params: string[], opts?: SpawnOptions & SpawnRxExtras): Promise<string>;
|
package/lib/src/index.js
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
2
13
|
var __rest = (this && this.__rest) || function (s, e) {
|
3
14
|
var t = {};
|
4
15
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
@@ -95,11 +106,11 @@ function runDownPath(exe) {
|
|
95
106
|
* also doesn't do, unlike on POSIX.
|
96
107
|
*
|
97
108
|
* @param {string} exe The executable to run
|
98
|
-
* @param {
|
109
|
+
* @param {string[]} args The arguments to run
|
99
110
|
*
|
100
111
|
* @return {Object} The cmd and args to run
|
101
112
|
* @property {string} cmd The command to pass to spawn
|
102
|
-
* @property {
|
113
|
+
* @property {string[]} args The arguments to pass to spawn
|
103
114
|
*/
|
104
115
|
function findActualExecutable(exe, args) {
|
105
116
|
// POSIX can just execute scripts directly, no need for silly goosery
|
@@ -150,8 +161,8 @@ function findActualExecutable(exe, args) {
|
|
150
161
|
* return Observable.
|
151
162
|
*
|
152
163
|
* @param {string} exe The executable to run
|
153
|
-
* @param {
|
154
|
-
* @param {
|
164
|
+
* @param {string[]} params The parameters to pass to the child
|
165
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
155
166
|
*
|
156
167
|
* @return {Observable<string>} Returns an Observable that when subscribed
|
157
168
|
* to, will create a detached process. The
|
@@ -162,8 +173,7 @@ function findActualExecutable(exe, args) {
|
|
162
173
|
* the Observable will terminate with onError.
|
163
174
|
*/
|
164
175
|
function spawnDetached(exe, params, opts) {
|
165
|
-
|
166
|
-
var _a = findActualExecutable(exe, params), cmd = _a.cmd, args = _a.args;
|
176
|
+
var _a = findActualExecutable(exe, params !== null && params !== void 0 ? params : []), cmd = _a.cmd, args = _a.args;
|
167
177
|
if (!isWindows) {
|
168
178
|
return spawn(cmd, args, assign({}, opts || {}, { detached: true }));
|
169
179
|
}
|
@@ -177,8 +187,8 @@ function spawnDetached(exe, params, opts) {
|
|
177
187
|
* Spawns a process attached as a child of the current process.
|
178
188
|
*
|
179
189
|
* @param {string} exe The executable to run
|
180
|
-
* @param {
|
181
|
-
* @param {
|
190
|
+
* @param {string[]} params The parameters to pass to the child
|
191
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
182
192
|
*
|
183
193
|
* @return {Observable<string>} Returns an Observable that when subscribed
|
184
194
|
* to, will create a child process. The
|
@@ -189,22 +199,13 @@ function spawnDetached(exe, params, opts) {
|
|
189
199
|
* the Observable will terminate with onError.
|
190
200
|
*/
|
191
201
|
function spawn(exe, params, opts) {
|
192
|
-
|
193
|
-
|
194
|
-
opts = opts || {};
|
195
|
-
var spawnObs = rxjs_1.Observable.create(function (subj) {
|
202
|
+
opts = opts !== null && opts !== void 0 ? opts : {};
|
203
|
+
var spawnObs = new rxjs_1.Observable(function (subj) {
|
196
204
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
197
|
-
var
|
205
|
+
var stdin = opts.stdin, jobber = opts.jobber, split = opts.split, encoding = opts.encoding, spawnOpts = __rest(opts, ["stdin", "jobber", "split", "encoding"]);
|
198
206
|
var _a = findActualExecutable(exe, params), cmd = _a.cmd, args = _a.args;
|
199
|
-
d("spawning process: ".concat(cmd, " ").concat(args.join(), ", ").concat(JSON.stringify(
|
200
|
-
var
|
201
|
-
if ("jobber" in origOpts) {
|
202
|
-
delete origOpts.jobber;
|
203
|
-
}
|
204
|
-
if ("split" in origOpts) {
|
205
|
-
delete origOpts.split;
|
206
|
-
}
|
207
|
-
var proc = (0, child_process_1.spawn)(cmd, args, origOpts);
|
207
|
+
d("spawning process: ".concat(cmd, " ").concat(args.join(), ", ").concat(JSON.stringify(spawnOpts)));
|
208
|
+
var proc = (0, child_process_1.spawn)(cmd, args, spawnOpts);
|
208
209
|
var bufHandler = function (source) { return function (b) {
|
209
210
|
if (b.length < 1) {
|
210
211
|
return;
|
@@ -215,7 +216,7 @@ function spawn(exe, params, opts) {
|
|
215
216
|
chunk = b.toString();
|
216
217
|
}
|
217
218
|
else {
|
218
|
-
chunk = b.toString(
|
219
|
+
chunk = b.toString(encoding || "utf8");
|
219
220
|
}
|
220
221
|
}
|
221
222
|
catch (_a) {
|
@@ -226,7 +227,11 @@ function spawn(exe, params, opts) {
|
|
226
227
|
var ret = new rxjs_1.Subscription();
|
227
228
|
if (opts.stdin) {
|
228
229
|
if (proc.stdin) {
|
229
|
-
ret.add(opts.stdin.subscribe(
|
230
|
+
ret.add(opts.stdin.subscribe({
|
231
|
+
next: function (x) { return proc.stdin.write(x); },
|
232
|
+
error: subj.error.bind(subj),
|
233
|
+
complete: function () { return proc.stdin.end(); },
|
234
|
+
}));
|
230
235
|
}
|
231
236
|
else {
|
232
237
|
subj.error(new Error("opts.stdio conflicts with provided spawn opts.stdin observable, 'pipe' is required"));
|
@@ -296,7 +301,22 @@ function spawn(exe, params, opts) {
|
|
296
301
|
function wrapObservableInPromise(obs) {
|
297
302
|
return new Promise(function (res, rej) {
|
298
303
|
var out = "";
|
299
|
-
obs.subscribe(
|
304
|
+
obs.subscribe({
|
305
|
+
next: function (x) { return (out += x); },
|
306
|
+
error: function (e) { return rej(new Error("".concat(out, "\n").concat(e.message))); },
|
307
|
+
complete: function () { return res(out); },
|
308
|
+
});
|
309
|
+
});
|
310
|
+
}
|
311
|
+
function wrapObservableInSplitPromise(obs) {
|
312
|
+
return new Promise(function (res, rej) {
|
313
|
+
var out = "";
|
314
|
+
var err = "";
|
315
|
+
obs.subscribe({
|
316
|
+
next: function (x) { return (x.source === "stdout" ? (out += x.text) : (err += x.text)); },
|
317
|
+
error: function (e) { return rej(new Error("".concat(out, "\n").concat(e.message))); },
|
318
|
+
complete: function () { return res([out, err]); },
|
319
|
+
});
|
300
320
|
});
|
301
321
|
}
|
302
322
|
/**
|
@@ -304,7 +324,7 @@ function wrapObservableInPromise(obs) {
|
|
304
324
|
* into its own Process Group.
|
305
325
|
*
|
306
326
|
* @param {string} exe The executable to run
|
307
|
-
* @param {
|
327
|
+
* @param {string[]} params The parameters to pass to the child
|
308
328
|
* @param {Object} opts Options to pass to spawn.
|
309
329
|
*
|
310
330
|
* @return {Promise<string>} Returns an Promise that represents a detached
|
@@ -314,14 +334,18 @@ function wrapObservableInPromise(obs) {
|
|
314
334
|
* an Error.
|
315
335
|
*/
|
316
336
|
function spawnDetachedPromise(exe, params, opts) {
|
317
|
-
if (opts === void 0
|
318
|
-
|
337
|
+
if (opts === null || opts === void 0 ? void 0 : opts.split) {
|
338
|
+
return wrapObservableInSplitPromise(spawnDetached(exe, params, __assign(__assign({}, (opts !== null && opts !== void 0 ? opts : {})), { split: true })));
|
339
|
+
}
|
340
|
+
else {
|
341
|
+
return wrapObservableInPromise(spawnDetached(exe, params, __assign(__assign({}, (opts !== null && opts !== void 0 ? opts : {})), { split: false })));
|
342
|
+
}
|
319
343
|
}
|
320
344
|
/**
|
321
345
|
* Spawns a process as a child process.
|
322
346
|
*
|
323
347
|
* @param {string} exe The executable to run
|
324
|
-
* @param {
|
348
|
+
* @param {string[]} params The parameters to pass to the child
|
325
349
|
* @param {Object} opts Options to pass to spawn.
|
326
350
|
*
|
327
351
|
* @return {Promise<string>} Returns an Promise that represents a child
|
@@ -331,7 +355,11 @@ function spawnDetachedPromise(exe, params, opts) {
|
|
331
355
|
* an Error.
|
332
356
|
*/
|
333
357
|
function spawnPromise(exe, params, opts) {
|
334
|
-
if (opts === void 0
|
335
|
-
|
358
|
+
if (opts === null || opts === void 0 ? void 0 : opts.split) {
|
359
|
+
return wrapObservableInSplitPromise(spawn(exe, params, __assign(__assign({}, (opts !== null && opts !== void 0 ? opts : {})), { split: true })));
|
360
|
+
}
|
361
|
+
else {
|
362
|
+
return wrapObservableInPromise(spawn(exe, params, __assign(__assign({}, (opts !== null && opts !== void 0 ? opts : {})), { split: false })));
|
363
|
+
}
|
336
364
|
}
|
337
365
|
//# sourceMappingURL=index.js.map
|
package/lib/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,oDA8DC;AA8ED,sCAyBC;AA2DD,sBA+HC;AAiFD,oDAcC;AAqDD,oCAcC;AAtlBD,uDAAuD;AACvD,2BAA6B;AAC7B,yBAA2B;AAC3B,wBAA0B;AAC1B,sCAAwC;AAGxC,6BAAyE;AACzE,4CAA6C;AAC7C,+CAA+D;AAC/D,+BAA0B;AAE1B,IAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AAE/C,IAAM,CAAC,GAAG,IAAA,eAAK,EAAC,UAAU,CAAC,CAAC,CAAC,sCAAsC;AAEnE;;;;;;;GAOG;AACH,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC;QACH,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,sEAAsE;IACtE,aAAa;IAEb,uDAAuD;IACvD,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,CAAC,CAAC,sCAAsC,CAAC,CAAC;QAC1C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnC,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,CAAC,CAAC,iDAA0C,MAAM,CAAE,CAAC,CAAC;QACtD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,IAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GA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AO,uBAAuB,CAC5B,KAAK,CAAC,GAAG,EAAE,MAAM,wBAAO,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,KAAE,KAAK,EAAE,KAAK,IAAG,CACtD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "spawn-rx",
|
3
|
-
"version": "
|
3
|
+
"version": "5.0.0",
|
4
4
|
"description": "An Rx-version of child_process.spawn",
|
5
5
|
"scripts": {
|
6
6
|
"doc": "echo \"esdoc may not work correctly\" && esdoc -c ./esdoc.json",
|
@@ -57,4 +57,4 @@
|
|
57
57
|
"typescript-eslint": "^8.14.0",
|
58
58
|
"uuid": "3.0.1"
|
59
59
|
}
|
60
|
-
}
|
60
|
+
}
|
package/src/index.ts
CHANGED
@@ -7,7 +7,7 @@ import * as assign from "lodash.assign";
|
|
7
7
|
import type { Observer, Subject } from "rxjs";
|
8
8
|
import { Observable, Subscription, AsyncSubject, of, merge } from "rxjs";
|
9
9
|
import { map, reduce } from "rxjs/operators";
|
10
|
-
import { spawn as spawnOg } from "child_process";
|
10
|
+
import { spawn as spawnOg, SpawnOptions } from "child_process";
|
11
11
|
import Debug from "debug";
|
12
12
|
|
13
13
|
const isWindows = process.platform === "win32";
|
@@ -77,18 +77,18 @@ function runDownPath(exe: string): string {
|
|
77
77
|
* also doesn't do, unlike on POSIX.
|
78
78
|
*
|
79
79
|
* @param {string} exe The executable to run
|
80
|
-
* @param {
|
80
|
+
* @param {string[]} args The arguments to run
|
81
81
|
*
|
82
82
|
* @return {Object} The cmd and args to run
|
83
83
|
* @property {string} cmd The command to pass to spawn
|
84
|
-
* @property {
|
84
|
+
* @property {string[]} args The arguments to pass to spawn
|
85
85
|
*/
|
86
86
|
export function findActualExecutable(
|
87
87
|
exe: string,
|
88
|
-
args:
|
88
|
+
args: string[],
|
89
89
|
): {
|
90
90
|
cmd: string;
|
91
|
-
args:
|
91
|
+
args: string[];
|
92
92
|
} {
|
93
93
|
// POSIX can just execute scripts directly, no need for silly goosery
|
94
94
|
if (process.platform !== "win32") {
|
@@ -147,14 +147,73 @@ export function findActualExecutable(
|
|
147
147
|
return { cmd: exe, args: args };
|
148
148
|
}
|
149
149
|
|
150
|
+
export type SpawnRxExtras = {
|
151
|
+
stdin?: Observable<string>;
|
152
|
+
split?: boolean;
|
153
|
+
jobber?: boolean;
|
154
|
+
encoding?: BufferEncoding;
|
155
|
+
};
|
156
|
+
|
157
|
+
export type OutputLine = {
|
158
|
+
source: "stdout" | "stderr";
|
159
|
+
text: string;
|
160
|
+
};
|
161
|
+
|
162
|
+
|
150
163
|
/**
|
151
164
|
* Spawns a process but detached from the current process. The process is put
|
152
165
|
* into its own Process Group that can be killed by unsubscribing from the
|
153
166
|
* return Observable.
|
154
167
|
*
|
155
168
|
* @param {string} exe The executable to run
|
156
|
-
* @param {
|
157
|
-
* @param {
|
169
|
+
* @param {string[]} params The parameters to pass to the child
|
170
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
171
|
+
*
|
172
|
+
* @return {Observable<OutputLine>} Returns an Observable that when subscribed
|
173
|
+
* to, will create a detached process. The
|
174
|
+
* process output will be streamed to this
|
175
|
+
* Observable, and if unsubscribed from, the
|
176
|
+
* process will be terminated early. If the
|
177
|
+
* process terminates with a non-zero value,
|
178
|
+
* the Observable will terminate with onError.
|
179
|
+
*/
|
180
|
+
export function spawnDetached(
|
181
|
+
exe: string,
|
182
|
+
params: string[],
|
183
|
+
opts: SpawnOptions & SpawnRxExtras & { split: true },
|
184
|
+
): Observable<OutputLine>;
|
185
|
+
|
186
|
+
/**
|
187
|
+
* Spawns a process but detached from the current process. The process is put
|
188
|
+
* into its own Process Group that can be killed by unsubscribing from the
|
189
|
+
* return Observable.
|
190
|
+
*
|
191
|
+
* @param {string} exe The executable to run
|
192
|
+
* @param {string[]} params The parameters to pass to the child
|
193
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
194
|
+
*
|
195
|
+
* @return {Observable<string>} Returns an Observable that when subscribed
|
196
|
+
* to, will create a detached process. The
|
197
|
+
* process output will be streamed to this
|
198
|
+
* Observable, and if unsubscribed from, the
|
199
|
+
* process will be terminated early. If the
|
200
|
+
* process terminates with a non-zero value,
|
201
|
+
* the Observable will terminate with onError.
|
202
|
+
*/
|
203
|
+
export function spawnDetached(
|
204
|
+
exe: string,
|
205
|
+
params: string[],
|
206
|
+
opts?: SpawnOptions & SpawnRxExtras & { split: false | undefined },
|
207
|
+
): Observable<string>;
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Spawns a process but detached from the current process. The process is put
|
211
|
+
* into its own Process Group that can be killed by unsubscribing from the
|
212
|
+
* return Observable.
|
213
|
+
*
|
214
|
+
* @param {string} exe The executable to run
|
215
|
+
* @param {string[]} params The parameters to pass to the child
|
216
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
158
217
|
*
|
159
218
|
* @return {Observable<string>} Returns an Observable that when subscribed
|
160
219
|
* to, will create a detached process. The
|
@@ -166,10 +225,10 @@ export function findActualExecutable(
|
|
166
225
|
*/
|
167
226
|
export function spawnDetached(
|
168
227
|
exe: string,
|
169
|
-
params:
|
170
|
-
opts
|
171
|
-
): Observable<string> {
|
172
|
-
const { cmd, args } = findActualExecutable(exe, params);
|
228
|
+
params: string[],
|
229
|
+
opts?: SpawnOptions & SpawnRxExtras,
|
230
|
+
): Observable<string> | Observable<OutputLine> {
|
231
|
+
const { cmd, args } = findActualExecutable(exe, params ?? []);
|
173
232
|
|
174
233
|
if (!isWindows) {
|
175
234
|
return spawn(cmd, args, assign({}, opts || {}, { detached: true }));
|
@@ -195,8 +254,29 @@ export function spawnDetached(
|
|
195
254
|
* Spawns a process attached as a child of the current process.
|
196
255
|
*
|
197
256
|
* @param {string} exe The executable to run
|
198
|
-
* @param {
|
199
|
-
* @param {
|
257
|
+
* @param {string[]} params The parameters to pass to the child
|
258
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
259
|
+
*
|
260
|
+
* @return {Observable<OutputLine>} Returns an Observable that when subscribed
|
261
|
+
* to, will create a child process. The
|
262
|
+
* process output will be streamed to this
|
263
|
+
* Observable, and if unsubscribed from, the
|
264
|
+
* process will be terminated early. If the
|
265
|
+
* process terminates with a non-zero value,
|
266
|
+
* the Observable will terminate with onError.
|
267
|
+
*/
|
268
|
+
export function spawn(
|
269
|
+
exe: string,
|
270
|
+
params: string[],
|
271
|
+
opts: SpawnOptions & SpawnRxExtras & { split: true },
|
272
|
+
): Observable<OutputLine>;
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Spawns a process attached as a child of the current process.
|
276
|
+
*
|
277
|
+
* @param {string} exe The executable to run
|
278
|
+
* @param {string[]} params The parameters to pass to the child
|
279
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
200
280
|
*
|
201
281
|
* @return {Observable<string>} Returns an Observable that when subscribed
|
202
282
|
* to, will create a child process. The
|
@@ -206,66 +286,73 @@ export function spawnDetached(
|
|
206
286
|
* process terminates with a non-zero value,
|
207
287
|
* the Observable will terminate with onError.
|
208
288
|
*/
|
289
|
+
export function spawn(
|
290
|
+
exe: string,
|
291
|
+
params: string[],
|
292
|
+
opts?: SpawnOptions & SpawnRxExtras & { split: false | undefined },
|
293
|
+
): Observable<string>;
|
209
294
|
|
210
|
-
|
295
|
+
/**
|
296
|
+
* Spawns a process attached as a child of the current process.
|
297
|
+
*
|
298
|
+
* @param {string} exe The executable to run
|
299
|
+
* @param {string[]} params The parameters to pass to the child
|
300
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
301
|
+
*
|
302
|
+
* @return {Observable<string>} Returns an Observable that when subscribed
|
303
|
+
* to, will create a child process. The
|
304
|
+
* process output will be streamed to this
|
305
|
+
* Observable, and if unsubscribed from, the
|
306
|
+
* process will be terminated early. If the
|
307
|
+
* process terminates with a non-zero value,
|
308
|
+
* the Observable will terminate with onError.
|
309
|
+
*/
|
310
|
+
export function spawn(
|
211
311
|
exe: string,
|
212
|
-
params:
|
213
|
-
opts
|
214
|
-
): Observable<
|
215
|
-
opts = opts
|
216
|
-
const spawnObs = Observable
|
217
|
-
(
|
218
|
-
subj: Observer<{
|
219
|
-
source: any;
|
220
|
-
text: any;
|
221
|
-
}>,
|
222
|
-
) => {
|
312
|
+
params: string[],
|
313
|
+
opts?: SpawnOptions & SpawnRxExtras,
|
314
|
+
): Observable<string> | Observable<OutputLine> {
|
315
|
+
opts = opts ?? {};
|
316
|
+
const spawnObs: Observable<OutputLine> = new Observable(
|
317
|
+
(subj: Observer<OutputLine>) => {
|
223
318
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
224
|
-
const {
|
319
|
+
const { stdin, jobber, split, encoding, ...spawnOpts } = opts;
|
225
320
|
const { cmd, args } = findActualExecutable(exe, params);
|
226
321
|
d(
|
227
|
-
`spawning process: ${cmd} ${args.join()}, ${JSON.stringify(
|
228
|
-
optsWithoutStdIn,
|
229
|
-
)}`,
|
322
|
+
`spawning process: ${cmd} ${args.join()}, ${JSON.stringify(spawnOpts)}`,
|
230
323
|
);
|
231
|
-
const origOpts = assign({}, optsWithoutStdIn);
|
232
|
-
if ("jobber" in origOpts) {
|
233
|
-
delete origOpts.jobber;
|
234
|
-
}
|
235
|
-
if ("split" in origOpts) {
|
236
|
-
delete origOpts.split;
|
237
|
-
}
|
238
324
|
|
239
|
-
const proc = spawnOg(cmd, args,
|
325
|
+
const proc = spawnOg(cmd, args, spawnOpts);
|
240
326
|
|
241
|
-
const bufHandler =
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
327
|
+
const bufHandler =
|
328
|
+
(source: "stdout" | "stderr") => (b: string | Buffer) => {
|
329
|
+
if (b.length < 1) {
|
330
|
+
return;
|
331
|
+
}
|
332
|
+
let chunk = "<< String sent back was too long >>";
|
333
|
+
try {
|
334
|
+
if (typeof b === "string") {
|
335
|
+
chunk = b.toString();
|
336
|
+
} else {
|
337
|
+
chunk = b.toString(encoding || "utf8");
|
338
|
+
}
|
339
|
+
} catch {
|
340
|
+
chunk = `<< Lost chunk of process output for ${exe} - length was ${b.length}>>`;
|
251
341
|
}
|
252
|
-
} catch {
|
253
|
-
chunk = `<< Lost chunk of process output for ${exe} - length was ${b.length}>>`;
|
254
|
-
}
|
255
342
|
|
256
|
-
|
257
|
-
|
343
|
+
subj.next({ source: source, text: chunk });
|
344
|
+
};
|
258
345
|
|
259
346
|
const ret = new Subscription();
|
260
347
|
|
261
348
|
if (opts.stdin) {
|
262
349
|
if (proc.stdin) {
|
263
350
|
ret.add(
|
264
|
-
opts.stdin.subscribe(
|
265
|
-
(x: any) => proc.stdin.write(x),
|
266
|
-
subj.error.bind(subj),
|
267
|
-
() => proc.stdin.end(),
|
268
|
-
),
|
351
|
+
opts.stdin.subscribe({
|
352
|
+
next: (x: any) => proc.stdin.write(x),
|
353
|
+
error: subj.error.bind(subj),
|
354
|
+
complete: () => proc.stdin.end(),
|
355
|
+
}),
|
269
356
|
);
|
270
357
|
} else {
|
271
358
|
subj.error(
|
@@ -349,15 +436,28 @@ export function spawn<T = string>(
|
|
349
436
|
return opts.split ? spawnObs : spawnObs.pipe(map((x: any) => x?.text));
|
350
437
|
}
|
351
438
|
|
352
|
-
function wrapObservableInPromise
|
439
|
+
function wrapObservableInPromise(obs: Observable<string>) {
|
353
440
|
return new Promise<string>((res, rej) => {
|
354
441
|
let out = "";
|
355
442
|
|
356
|
-
obs.subscribe(
|
357
|
-
(x) => (out += x),
|
358
|
-
(e) => rej(new Error(`${out}\n${e.message}`)),
|
359
|
-
() => res(out),
|
360
|
-
);
|
443
|
+
obs.subscribe({
|
444
|
+
next: (x) => (out += x),
|
445
|
+
error: (e) => rej(new Error(`${out}\n${e.message}`)),
|
446
|
+
complete: () => res(out),
|
447
|
+
});
|
448
|
+
});
|
449
|
+
}
|
450
|
+
|
451
|
+
function wrapObservableInSplitPromise(obs: Observable<OutputLine>) {
|
452
|
+
return new Promise<[string, string]>((res, rej) => {
|
453
|
+
let out = "";
|
454
|
+
let err = "";
|
455
|
+
|
456
|
+
obs.subscribe({
|
457
|
+
next: (x) => (x.source === "stdout" ? (out += x.text) : (err += x.text)),
|
458
|
+
error: (e) => rej(new Error(`${out}\n${e.message}`)),
|
459
|
+
complete: () => res([out, err]),
|
460
|
+
});
|
361
461
|
});
|
362
462
|
}
|
363
463
|
|
@@ -366,7 +466,47 @@ function wrapObservableInPromise<T>(obs: Observable<T>) {
|
|
366
466
|
* into its own Process Group.
|
367
467
|
*
|
368
468
|
* @param {string} exe The executable to run
|
369
|
-
* @param {
|
469
|
+
* @param {string[]} params The parameters to pass to the child
|
470
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
471
|
+
*
|
472
|
+
* @return {Promise<[string, string]>} Returns an Promise that represents a detached
|
473
|
+
* process. The value returned is the process
|
474
|
+
* output. If the process terminates with a
|
475
|
+
* non-zero value, the Promise will resolve with
|
476
|
+
* an Error.
|
477
|
+
*/
|
478
|
+
export function spawnDetachedPromise(
|
479
|
+
exe: string,
|
480
|
+
params: string[],
|
481
|
+
opts: SpawnOptions & SpawnRxExtras & { split: true },
|
482
|
+
): Promise<[string, string]>;
|
483
|
+
|
484
|
+
/**
|
485
|
+
* Spawns a process but detached from the current process. The process is put
|
486
|
+
* into its own Process Group.
|
487
|
+
*
|
488
|
+
* @param {string} exe The executable to run
|
489
|
+
* @param {string[]} params The parameters to pass to the child
|
490
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
491
|
+
*
|
492
|
+
* @return {Promise<string>} Returns an Promise that represents a detached
|
493
|
+
* process. The value returned is the process
|
494
|
+
* output. If the process terminates with a
|
495
|
+
* non-zero value, the Promise will resolve with
|
496
|
+
* an Error.
|
497
|
+
*/
|
498
|
+
export function spawnDetachedPromise(
|
499
|
+
exe: string,
|
500
|
+
params: string[],
|
501
|
+
opts?: SpawnOptions & SpawnRxExtras & { split: false | undefined },
|
502
|
+
): Promise<string>;
|
503
|
+
|
504
|
+
/**
|
505
|
+
* Spawns a process but detached from the current process. The process is put
|
506
|
+
* into its own Process Group.
|
507
|
+
*
|
508
|
+
* @param {string} exe The executable to run
|
509
|
+
* @param {string[]} params The parameters to pass to the child
|
370
510
|
* @param {Object} opts Options to pass to spawn.
|
371
511
|
*
|
372
512
|
* @return {Promise<string>} Returns an Promise that represents a detached
|
@@ -377,17 +517,63 @@ function wrapObservableInPromise<T>(obs: Observable<T>) {
|
|
377
517
|
*/
|
378
518
|
export function spawnDetachedPromise(
|
379
519
|
exe: string,
|
380
|
-
params:
|
381
|
-
opts
|
382
|
-
): Promise<string> {
|
383
|
-
|
520
|
+
params: string[],
|
521
|
+
opts?: SpawnOptions & SpawnRxExtras,
|
522
|
+
): Promise<string> | Promise<[string, string]> {
|
523
|
+
if (opts?.split) {
|
524
|
+
return wrapObservableInSplitPromise(
|
525
|
+
spawnDetached(exe, params, { ...(opts ?? {}), split: true }),
|
526
|
+
);
|
527
|
+
} else {
|
528
|
+
return wrapObservableInPromise(
|
529
|
+
spawnDetached(exe, params, { ...(opts ?? {}), split: false }),
|
530
|
+
);
|
531
|
+
}
|
384
532
|
}
|
385
533
|
|
386
534
|
/**
|
387
535
|
* Spawns a process as a child process.
|
388
536
|
*
|
389
537
|
* @param {string} exe The executable to run
|
390
|
-
* @param {
|
538
|
+
* @param {string[]} params The parameters to pass to the child
|
539
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
540
|
+
*
|
541
|
+
* @return {Promise<[string, string]>} Returns an Promise that represents a child
|
542
|
+
* process. The value returned is the process
|
543
|
+
* output. If the process terminates with a
|
544
|
+
* non-zero value, the Promise will resolve with
|
545
|
+
* an Error.
|
546
|
+
*/
|
547
|
+
export function spawnPromise(
|
548
|
+
exe: string,
|
549
|
+
params: string[],
|
550
|
+
opts: SpawnOptions & SpawnRxExtras & { split: true },
|
551
|
+
): Promise<[string, string]>;
|
552
|
+
|
553
|
+
/**
|
554
|
+
* Spawns a process as a child process.
|
555
|
+
*
|
556
|
+
* @param {string} exe The executable to run
|
557
|
+
* @param {string[]} params The parameters to pass to the child
|
558
|
+
* @param {SpawnOptions & SpawnRxExtras} opts Options to pass to spawn.
|
559
|
+
*
|
560
|
+
* @return {Promise<string>} Returns an Promise that represents a child
|
561
|
+
* process. The value returned is the process
|
562
|
+
* output. If the process terminates with a
|
563
|
+
* non-zero value, the Promise will resolve with
|
564
|
+
* an Error.
|
565
|
+
*/
|
566
|
+
export function spawnPromise(
|
567
|
+
exe: string,
|
568
|
+
params: string[],
|
569
|
+
opts?: SpawnOptions & SpawnRxExtras,
|
570
|
+
): Promise<string>;
|
571
|
+
|
572
|
+
/**
|
573
|
+
* Spawns a process as a child process.
|
574
|
+
*
|
575
|
+
* @param {string} exe The executable to run
|
576
|
+
* @param {string[]} params The parameters to pass to the child
|
391
577
|
* @param {Object} opts Options to pass to spawn.
|
392
578
|
*
|
393
579
|
* @return {Promise<string>} Returns an Promise that represents a child
|
@@ -398,8 +584,16 @@ export function spawnDetachedPromise(
|
|
398
584
|
*/
|
399
585
|
export function spawnPromise(
|
400
586
|
exe: string,
|
401
|
-
params:
|
402
|
-
opts
|
403
|
-
): Promise<string> {
|
404
|
-
|
587
|
+
params: string[],
|
588
|
+
opts?: SpawnOptions & SpawnRxExtras,
|
589
|
+
): Promise<string> | Promise<[string, string]> {
|
590
|
+
if (opts?.split) {
|
591
|
+
return wrapObservableInSplitPromise(
|
592
|
+
spawn(exe, params, { ...(opts ?? {}), split: true }),
|
593
|
+
);
|
594
|
+
} else {
|
595
|
+
return wrapObservableInPromise(
|
596
|
+
spawn(exe, params, { ...(opts ?? {}), split: false }),
|
597
|
+
);
|
598
|
+
}
|
405
599
|
}
|
package/test/spawn.ts
CHANGED
@@ -18,6 +18,20 @@ describe("The spawnPromise method", function () {
|
|
18
18
|
const result = await spawnPromise("uuid", []);
|
19
19
|
expect(result.match(uuidRegex)).to.be.ok;
|
20
20
|
});
|
21
|
+
|
22
|
+
it("should split stdout and stderr when we call uuid", async function () {
|
23
|
+
// NB: Since we get run via npm run test, we know that npm bins are in our
|
24
|
+
// PATH.
|
25
|
+
const result = await spawnPromise("uuid", [], { split: true});
|
26
|
+
expect(result[0].match(uuidRegex)).to.be.ok;
|
27
|
+
});
|
28
|
+
|
29
|
+
it("should not stdout and stderr when we call uuid with split false", async function () {
|
30
|
+
// NB: Since we get run via npm run test, we know that npm bins are in our
|
31
|
+
// PATH.
|
32
|
+
const result = await spawnPromise("uuid", [], { split: false});
|
33
|
+
expect(result.match(uuidRegex)).to.be.ok;
|
34
|
+
});
|
21
35
|
});
|
22
36
|
|
23
37
|
describe("The spawnDetachedPromise method", function () {
|