spawn-rx 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/src/index.js +17 -2
- package/lib/src/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +17 -3
- package/test/spawn.ts +14 -2
package/lib/src/index.js
CHANGED
@@ -276,6 +276,7 @@ function spawn(exe, params, opts) {
|
|
276
276
|
pipesClosed.subscribe(function () {
|
277
277
|
var e = new Error("Failed with exit code: ".concat(code));
|
278
278
|
e.exitCode = code;
|
279
|
+
e.code = code;
|
279
280
|
subj.error(e);
|
280
281
|
});
|
281
282
|
}
|
@@ -303,7 +304,14 @@ function wrapObservableInPromise(obs) {
|
|
303
304
|
var out = "";
|
304
305
|
obs.subscribe({
|
305
306
|
next: function (x) { return (out += x); },
|
306
|
-
error: function (e) {
|
307
|
+
error: function (e) {
|
308
|
+
var err = new Error("".concat(out, "\n").concat(e.message));
|
309
|
+
if ("exitCode" in e) {
|
310
|
+
err.exitCode = e.exitCode;
|
311
|
+
err.code = e.exitCode;
|
312
|
+
}
|
313
|
+
rej(err);
|
314
|
+
},
|
307
315
|
complete: function () { return res(out); },
|
308
316
|
});
|
309
317
|
});
|
@@ -314,7 +322,14 @@ function wrapObservableInSplitPromise(obs) {
|
|
314
322
|
var err = "";
|
315
323
|
obs.subscribe({
|
316
324
|
next: function (x) { return (x.source === "stdout" ? (out += x.text) : (err += x.text)); },
|
317
|
-
error: function (e) {
|
325
|
+
error: function (e) {
|
326
|
+
var err = new Error("".concat(out, "\n").concat(e.message));
|
327
|
+
if ("exitCode" in e) {
|
328
|
+
err.exitCode = e.exitCode;
|
329
|
+
err.code = e.exitCode;
|
330
|
+
}
|
331
|
+
rej(err);
|
332
|
+
},
|
318
333
|
complete: function () { return res([out, err]); },
|
319
334
|
});
|
320
335
|
});
|
package/lib/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;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,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,KAAE,KAAK,EAAE,KAAK,IAAG,CAC9D,CAAC;IACJ,CAAC;AACH,CAAC;AAwCD;;;;;;;;;;;;GAYG;AACH,SAAgB,YAAY,CAC1B,GAAW,EACX,MAAgB,EAChB,IAAmC;IAEnC,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,EAAE,CAAC;QAChB,OAAO,4BAA4B,CACjC,KAAK,CAAC,GAAG,EAAE,MAAM,wBAAO,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,KAAE,KAAK,EAAE,IAAI,IAAG,CACrD,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,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
package/src/index.ts
CHANGED
@@ -159,7 +159,6 @@ export type OutputLine = {
|
|
159
159
|
text: string;
|
160
160
|
};
|
161
161
|
|
162
|
-
|
163
162
|
/**
|
164
163
|
* Spawns a process but detached from the current process. The process is put
|
165
164
|
* into its own Process Group that can be killed by unsubscribing from the
|
@@ -406,6 +405,7 @@ export function spawn(
|
|
406
405
|
pipesClosed.subscribe(() => {
|
407
406
|
const e: any = new Error(`Failed with exit code: ${code}`);
|
408
407
|
e.exitCode = code;
|
408
|
+
e.code = code;
|
409
409
|
|
410
410
|
subj.error(e);
|
411
411
|
});
|
@@ -442,7 +442,14 @@ function wrapObservableInPromise(obs: Observable<string>) {
|
|
442
442
|
|
443
443
|
obs.subscribe({
|
444
444
|
next: (x) => (out += x),
|
445
|
-
error: (e) =>
|
445
|
+
error: (e) => {
|
446
|
+
const err: any = new Error(`${out}\n${e.message}`);
|
447
|
+
if ("exitCode" in e) {
|
448
|
+
err.exitCode = e.exitCode;
|
449
|
+
err.code = e.exitCode;
|
450
|
+
}
|
451
|
+
rej(err);
|
452
|
+
},
|
446
453
|
complete: () => res(out),
|
447
454
|
});
|
448
455
|
});
|
@@ -455,7 +462,14 @@ function wrapObservableInSplitPromise(obs: Observable<OutputLine>) {
|
|
455
462
|
|
456
463
|
obs.subscribe({
|
457
464
|
next: (x) => (x.source === "stdout" ? (out += x.text) : (err += x.text)),
|
458
|
-
error: (e) =>
|
465
|
+
error: (e) => {
|
466
|
+
const err: any = new Error(`${out}\n${e.message}`);
|
467
|
+
if ("exitCode" in e) {
|
468
|
+
err.exitCode = e.exitCode;
|
469
|
+
err.code = e.exitCode;
|
470
|
+
}
|
471
|
+
rej(err);
|
472
|
+
},
|
459
473
|
complete: () => res([out, err]),
|
460
474
|
});
|
461
475
|
});
|
package/test/spawn.ts
CHANGED
@@ -22,14 +22,26 @@ describe("The spawnPromise method", function () {
|
|
22
22
|
it("should split stdout and stderr when we call uuid", async function () {
|
23
23
|
// NB: Since we get run via npm run test, we know that npm bins are in our
|
24
24
|
// PATH.
|
25
|
-
const result = await spawnPromise("uuid", [], { split: true});
|
25
|
+
const result = await spawnPromise("uuid", [], { split: true });
|
26
26
|
expect(result[0].match(uuidRegex)).to.be.ok;
|
27
|
+
expect(result[1].match(uuidRegex)).to.not.be.ok;
|
28
|
+
});
|
29
|
+
|
30
|
+
it("should retur nthe exit code", async function () {
|
31
|
+
// NB: Since we get run via npm run test, we know that npm bins are in our
|
32
|
+
// PATH.
|
33
|
+
try {
|
34
|
+
await spawnPromise("false", [], { split: true });
|
35
|
+
expect(false).to.be.true;
|
36
|
+
} catch (e) {
|
37
|
+
expect(e.code).to.be.equal(1);
|
38
|
+
}
|
27
39
|
});
|
28
40
|
|
29
41
|
it("should not stdout and stderr when we call uuid with split false", async function () {
|
30
42
|
// NB: Since we get run via npm run test, we know that npm bins are in our
|
31
43
|
// PATH.
|
32
|
-
const result = await spawnPromise("uuid", [], { split: false});
|
44
|
+
const result = await spawnPromise("uuid", [], { split: false });
|
33
45
|
expect(result.match(uuidRegex)).to.be.ok;
|
34
46
|
});
|
35
47
|
});
|