spawn-rx 2.0.9 → 3.0.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.
@@ -1,15 +1,15 @@
1
- import { expect } from 'chai';
2
- import './support';
3
-
4
- function delay(ms: number) {
5
- return new Promise((resolve) => {
6
- setTimeout(resolve, ms);
7
- });
8
- }
9
-
10
- describe('The test runner', function () {
11
- it('should pass this test', async function () {
12
- await delay(1000);
13
- expect(true).to.be.ok;
14
- });
15
- });
1
+ import { expect } from 'chai';
2
+ import './support';
3
+
4
+ function delay(ms: number) {
5
+ return new Promise((resolve) => {
6
+ setTimeout(resolve, ms);
7
+ });
8
+ }
9
+
10
+ describe('The test runner', function () {
11
+ it('should pass this test', async function () {
12
+ await delay(1000);
13
+ expect(true).to.be.ok;
14
+ });
15
+ });
package/test/spawn.ts CHANGED
@@ -1,102 +1,102 @@
1
- import { expect } from 'chai';
2
- import './support';
3
-
4
- import { spawn, spawnPromise, spawnDetachedPromise } from '../src/index';
5
-
6
- import { Observable } from 'rxjs';
7
-
8
- const uuidRegex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
9
-
10
- describe('The spawnPromise method', function() {
11
- it('should return a uuid when we call uuid', async function() {
12
- // NB: Since we get run via npm run test, we know that npm bins are in our
13
- // PATH.
14
- let result = await spawnPromise('uuid', []);
15
- expect(result.match(uuidRegex)).to.be.ok;
16
- });
17
- });
18
-
19
- describe('The spawnDetachedPromise method', function() {
20
- it('should return a uuid when we call uuid', async function() {
21
- // NB: Since we get run via npm run test, we know that npm bins are in our
22
- // PATH.
23
- let result = await spawnDetachedPromise('uuid', ['--help']);
24
- expect(result.length > 10).to.be.ok;
25
- });
26
- });
27
-
28
- function wrapSplitObservableInPromise(obs: Observable<{
29
- source: any,
30
- text: any
31
- }>): Promise<{
32
- stderr: string,
33
- stdout: string,
34
- error: Error | undefined
35
- }> {
36
- return new Promise((res) => {
37
- let out = {stderr: '', stdout: '', error: undefined };
38
-
39
- obs.subscribe(
40
- (x) => {
41
- if (x.source === 'stdout') {
42
- out.stdout += x.text;
43
- } else {
44
- out.stderr += x.text;
45
- }
46
- },
47
- (e) => { out.error = e; res(out); },
48
- () => res(out));
49
- });
50
- }
51
-
52
- describe('The spawn method', function() {
53
- it('should return a disposable subscription', async function() {
54
- // this only check the unsubscribe goes w/o error, not that the spawned process is killed
55
- // (difficult to do that, maybe iterate through child processes and check ?)
56
- spawn('sleep', ['2']).subscribe().unsubscribe();
57
- });
58
-
59
- it('should return split stderr in a inner tag when called with split', async function() {
60
- // provide an invalid param to uuid so it complains on stderr
61
- let rxSpawn: Observable<{ source: any, text: any }> = spawn('uuid', ['foo'], {split: true}) as any;
62
- let result = await wrapSplitObservableInPromise(rxSpawn);
63
- expect(result.stderr.length > 10).to.be.ok;
64
- expect(result.stdout).to.be.empty;
65
- expect(result.error).to.be.an('error');
66
- });
67
-
68
- it('should return split stdout in a inner tag when called with split', async function() {
69
- let rxSpawn: Observable<{ source: any, text: any }> = spawn('uuid', [], {split: true});
70
- let result = await wrapSplitObservableInPromise(rxSpawn);
71
- expect(result.stdout.match(uuidRegex)).to.be.ok;
72
- expect(result.stderr).to.be.empty;
73
- expect(result.error).to.be.undefined;
74
- });
75
-
76
- it('should ignore stderr if options.stdio = ignore', async function() {
77
- let rxSpawn: Observable<{ source: any, text: any }> = spawn('uuid', ['foo'], {split: true, stdio: [null, null, 'ignore']});
78
- let result = await wrapSplitObservableInPromise(rxSpawn);
79
- expect(result.stderr).to.be.empty;
80
- });
81
-
82
- it('should ignore stdout if options.stdio = inherit', async function() {
83
- let rxSpawn: Observable<{ source: any, text: any }> = spawn('uuid', [], {split: true, stdio: [null, 'inherit', null]});
84
- let result = await wrapSplitObservableInPromise(rxSpawn);
85
- expect(result.stdout).to.be.empty;
86
- });
87
-
88
- it('should croak if stdin is provided but stdio.stdin is disabled', async function() {
89
- let stdin = Observable.of('a');
90
- let rxSpawn: Observable<{ source: any, text: any }> = spawn('marked', [], {split: true, stdin: stdin, stdio: ['ignore', null, null]});
91
- let result = await wrapSplitObservableInPromise(rxSpawn);
92
- expect(result.error).to.be.an('error');
93
- });
94
-
95
- it('should subscribe to provided stdin', async function() {
96
- let stdin = Observable.of('a');
97
- let rxSpawn: Observable<{ source: any, text: any }> = spawn('marked', [], {split: true, stdin: stdin});
98
- let result = await wrapSplitObservableInPromise(rxSpawn);
99
- expect(result.stdout.trim()).to.be.equal('<p>a</p>');
100
- });
101
-
102
- });
1
+ import { expect } from 'chai';
2
+ import './support';
3
+
4
+ import { spawn, spawnPromise, spawnDetachedPromise } from '../src/index';
5
+
6
+ import { Observable, of } from 'rxjs';
7
+
8
+ const uuidRegex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
9
+
10
+ describe('The spawnPromise method', function() {
11
+ it('should return a uuid when we call uuid', async function() {
12
+ // NB: Since we get run via npm run test, we know that npm bins are in our
13
+ // PATH.
14
+ let result = await spawnPromise('uuid', []);
15
+ expect(result.match(uuidRegex)).to.be.ok;
16
+ });
17
+ });
18
+
19
+ describe('The spawnDetachedPromise method', function() {
20
+ it('should return a uuid when we call uuid', async function() {
21
+ // NB: Since we get run via npm run test, we know that npm bins are in our
22
+ // PATH.
23
+ let result = await spawnDetachedPromise('uuid', ['--help']);
24
+ expect(result.length > 10).to.be.ok;
25
+ });
26
+ });
27
+
28
+ function wrapSplitObservableInPromise(obs: Observable<{
29
+ source: any,
30
+ text: any
31
+ }>): Promise<{
32
+ stderr: string,
33
+ stdout: string,
34
+ error: Error | undefined
35
+ }> {
36
+ return new Promise((res) => {
37
+ let out = {stderr: '', stdout: '', error: undefined };
38
+
39
+ obs.subscribe(
40
+ (x) => {
41
+ if (x.source === 'stdout') {
42
+ out.stdout += x.text;
43
+ } else {
44
+ out.stderr += x.text;
45
+ }
46
+ },
47
+ (e) => { out.error = e; res(out); },
48
+ () => res(out));
49
+ });
50
+ }
51
+
52
+ describe('The spawn method', function() {
53
+ it('should return a disposable subscription', async function() {
54
+ // this only check the unsubscribe goes w/o error, not that the spawned process is killed
55
+ // (difficult to do that, maybe iterate through child processes and check ?)
56
+ spawn('sleep', ['2']).subscribe().unsubscribe();
57
+ });
58
+
59
+ it('should return split stderr in a inner tag when called with split', async function() {
60
+ // provide an invalid param to uuid so it complains on stderr
61
+ let rxSpawn: Observable<{ source: any, text: any }> = spawn('uuid', ['foo'], {split: true}) as any;
62
+ let result = await wrapSplitObservableInPromise(rxSpawn);
63
+ expect(result.stderr.length > 10).to.be.ok;
64
+ expect(result.stdout).to.be.empty;
65
+ expect(result.error).to.be.an('error');
66
+ });
67
+
68
+ it('should return split stdout in a inner tag when called with split', async function() {
69
+ let rxSpawn: Observable<{ source: any, text: any }> = spawn('uuid', [], {split: true});
70
+ let result = await wrapSplitObservableInPromise(rxSpawn);
71
+ expect(result.stdout.match(uuidRegex)).to.be.ok;
72
+ expect(result.stderr).to.be.empty;
73
+ expect(result.error).to.be.undefined;
74
+ });
75
+
76
+ it('should ignore stderr if options.stdio = ignore', async function() {
77
+ let rxSpawn: Observable<{ source: any, text: any }> = spawn('uuid', ['foo'], {split: true, stdio: [null, null, 'ignore']});
78
+ let result = await wrapSplitObservableInPromise(rxSpawn);
79
+ expect(result.stderr).to.be.empty;
80
+ });
81
+
82
+ it('should ignore stdout if options.stdio = inherit', async function() {
83
+ let rxSpawn: Observable<{ source: any, text: any }> = spawn('uuid', [], {split: true, stdio: [null, 'inherit', null]});
84
+ let result = await wrapSplitObservableInPromise(rxSpawn);
85
+ expect(result.stdout).to.be.empty;
86
+ });
87
+
88
+ it('should croak if stdin is provided but stdio.stdin is disabled', async function() {
89
+ let stdin = of('a');
90
+ let rxSpawn: Observable<{ source: any, text: any }> = spawn('marked', [], {split: true, stdin: stdin, stdio: ['ignore', null, null]});
91
+ let result = await wrapSplitObservableInPromise(rxSpawn);
92
+ expect(result.error).to.be.an('error');
93
+ });
94
+
95
+ it('should subscribe to provided stdin', async function() {
96
+ let stdin = of('a');
97
+ let rxSpawn: Observable<{ source: any, text: any }> = spawn('marked', [], {split: true, stdin: stdin});
98
+ let result = await wrapSplitObservableInPromise(rxSpawn);
99
+ expect(result.stdout.trim()).to.be.equal('<p>a</p>');
100
+ });
101
+
102
+ });
package/test/support.ts CHANGED
@@ -1,14 +1,14 @@
1
- import * as chai from 'chai';
2
- import * as chaiAsPromised from 'chai-as-promised';
3
-
4
- declare const global: any;
5
-
6
- chai.should();
7
- chai.use(chaiAsPromised);
8
-
9
- global.chai = chai;
10
- global.chaiAsPromised = chaiAsPromised;
11
- global.expect = chai.expect;
12
- global.AssertionError = chai.AssertionError;
13
- global.assert = chai.assert;
14
- global.Assertion = (chai as any).Assertion; //'Assertion' is not existing?
1
+ import * as chai from 'chai';
2
+ import * as chaiAsPromised from 'chai-as-promised';
3
+
4
+ declare const global: any;
5
+
6
+ chai.should();
7
+ chai.use(chaiAsPromised);
8
+
9
+ global.chai = chai;
10
+ global.chaiAsPromised = chaiAsPromised;
11
+ global.expect = chai.expect;
12
+ global.AssertionError = chai.AssertionError;
13
+ global.assert = chai.assert;
14
+ global.Assertion = (chai as any).Assertion; //'Assertion' is not existing?
package/tsconfig.json CHANGED
@@ -1,32 +1,29 @@
1
- {
2
- "compilerOptions": {
3
- "removeComments": false,
4
- "preserveConstEnums": true,
5
- "sourceMap": true,
6
- "declaration": true,
7
- "noImplicitAny": true,
8
- "noImplicitReturns": true,
9
- "suppressImplicitAnyIndexErrors": true,
10
- "strictNullChecks": true,
11
- "noUnusedLocals": true,
12
- "noImplicitThis": true,
13
- "noUnusedParameters": true,
14
- "module": "commonjs",
15
- "moduleResolution": "node",
16
- "pretty": true,
17
- "target": "es5",
18
- "outDir": "lib",
19
- "lib": ["dom", "es2015"],
20
- "typeRoots": [
21
- "./node_modules/@types"
22
- ]
23
- },
24
- "formatCodeOptions": {
25
- "indentSize": 2,
26
- "tabSize": 2
27
- },
28
- "exclude": [
29
- "node_modules",
30
- "lib"
31
- ]
1
+ {
2
+ "compilerOptions": {
3
+ "removeComments": false,
4
+ "preserveConstEnums": true,
5
+ "sourceMap": true,
6
+ "declaration": true,
7
+ "noImplicitAny": true,
8
+ "noImplicitReturns": true,
9
+ "suppressImplicitAnyIndexErrors": true,
10
+ "strictNullChecks": true,
11
+ "noUnusedLocals": true,
12
+ "noImplicitThis": true,
13
+ "noUnusedParameters": true,
14
+ "module": "commonjs",
15
+ "moduleResolution": "node",
16
+ "pretty": true,
17
+ "target": "es5",
18
+ "outDir": "lib",
19
+ "lib": ["dom", "es2015"]
20
+ },
21
+ "formatCodeOptions": {
22
+ "indentSize": 2,
23
+ "tabSize": 2
24
+ },
25
+ "exclude": [
26
+ "node_modules",
27
+ "lib"
28
+ ]
32
29
  }
package/tslint.json CHANGED
@@ -1,38 +1,40 @@
1
- {
2
- "rules": {
3
- "curly": true,
4
- "eofline": false,
5
- "align": [true, "parameters"],
6
- "class-name": true,
7
- "indent": [true, "spaces"],
8
- "max-line-length": [true, 150],
9
- "no-consecutive-blank-lines": [true],
10
- "no-trailing-whitespace": true,
11
- "no-duplicate-variable": true,
12
- "no-var-keyword": true,
13
- "no-empty": true,
14
- "no-unused-expression": true,
15
- "no-use-before-declare": true,
16
- "no-var-requires": true,
17
- "one-line": [true,
18
- "check-else",
19
- "check-whitespace",
20
- "check-open-brace"],
21
- "quotemark": [true,
22
- "single",
23
- "avoid-escape"],
24
- "semicolon": [true, "always"],
25
- "typedef-whitespace": [true, {
26
- "call-signature": "nospace",
27
- "index-signature": "nospace",
28
- "parameter": "nospace",
29
- "property-declaration": "nospace",
30
- "variable-declaration": "nospace"
31
- }],
32
- "whitespace": [true,
33
- "check-branch",
34
- "check-decl",
35
- "check-operator",
36
- "check-type"]
37
- }
1
+ {
2
+ "rules": {
3
+ "curly": true,
4
+ "eofline": false,
5
+ "align": [true, "parameters"],
6
+ "class-name": true,
7
+ "indent": [true, "spaces"],
8
+ "max-line-length": [true, 150],
9
+ "no-consecutive-blank-lines": [true],
10
+ "no-trailing-whitespace": true,
11
+ "no-duplicate-variable": true,
12
+ "no-var-keyword": true,
13
+ "no-empty": true,
14
+ "no-unused-expression-chai": true,
15
+ "no-use-before-declare": true,
16
+ "no-var-requires": true,
17
+ "one-line": [true,
18
+ "check-else",
19
+ "check-whitespace",
20
+ "check-open-brace"],
21
+ "quotemark": [true,
22
+ "single",
23
+ "avoid-escape"],
24
+ "semicolon": [true, "always"],
25
+ "typedef-whitespace": [true, {
26
+ "call-signature": "nospace",
27
+ "index-signature": "nospace",
28
+ "parameter": "nospace",
29
+ "property-declaration": "nospace",
30
+ "variable-declaration": "nospace"
31
+ }],
32
+ "whitespace": [true,
33
+ "check-branch",
34
+ "check-decl",
35
+ "check-operator",
36
+ "check-type"]
37
+ }, "rulesDirectory": [
38
+ "tslint-no-unused-expression-chai"
39
+ ]
38
40
  }
package/.npmignore DELETED
@@ -1,3 +0,0 @@
1
- vendor/jobber/Jobber
2
- vendor/jobber/Jobber.sln
3
- lib/test