spawn-rx 5.1.2 → 6.0.1

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,6 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-expressions */
2
- import { expect } from "chai";
3
- import "./support";
2
+ import { describe, expect, it } from "bun:test";
4
3
 
5
4
  function delay(ms: number) {
6
5
  return new Promise((resolve) => {
@@ -8,9 +7,9 @@ function delay(ms: number) {
8
7
  });
9
8
  }
10
9
 
11
- describe("The test runner", function () {
12
- it("should pass this test", async function () {
10
+ describe("The test runner", () => {
11
+ it("should pass this test", async () => {
13
12
  await delay(1000);
14
- expect(true).to.be.ok;
13
+ expect(true).toBeTruthy();
15
14
  });
16
15
  });
@@ -1,57 +1,42 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* eslint-disable @typescript-eslint/no-unused-expressions */
3
- import { expect } from "chai";
4
- import "./support";
5
-
6
- import { spawn, spawnPromise, spawnDetachedPromise } from "../src/index";
7
-
1
+ import { describe, expect, it } from "bun:test";
8
2
  import type { Observable } from "rxjs";
9
3
  import { of } from "rxjs";
4
+ import { spawn, spawnPromise } from "../src/index";
10
5
 
11
- const uuidRegex =
12
- /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
6
+ const uuidRegex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
13
7
 
14
- describe("The spawnPromise method", function () {
15
- it("should return a uuid when we call uuid", async function () {
8
+ describe("The spawnPromise method", () => {
9
+ it("should return a uuid when we call uuid", async () => {
16
10
  // NB: Since we get run via npm run test, we know that npm bins are in our
17
11
  // PATH.
18
12
  const result = await spawnPromise("uuid", []);
19
- expect(result.match(uuidRegex)).to.be.ok;
13
+ expect(result.match(uuidRegex)).toBeTruthy();
20
14
  });
21
15
 
22
- it("should split stdout and stderr when we call uuid", async function () {
16
+ it("should split stdout and stderr when we call uuid", async () => {
23
17
  // NB: Since we get run via npm run test, we know that npm bins are in our
24
18
  // PATH.
25
19
  const result = await spawnPromise("uuid", [], { split: true });
26
- expect(result[0].match(uuidRegex)).to.be.ok;
27
- expect(result[1].match(uuidRegex)).to.not.be.ok;
20
+ expect(result[0].match(uuidRegex)).toBeTruthy();
21
+ expect(result[1].match(uuidRegex)).toBeFalsy();
28
22
  });
29
23
 
30
- it("should retur nthe exit code", async function () {
24
+ it("should retur nthe exit code", async () => {
31
25
  // NB: Since we get run via npm run test, we know that npm bins are in our
32
26
  // PATH.
33
27
  try {
34
28
  await spawnPromise("false", [], { split: true });
35
- expect(false).to.be.true;
36
- } catch (e) {
37
- expect(e.code).to.be.equal(1);
29
+ expect(false).toBe(true);
30
+ } catch (e: any) {
31
+ expect(e.code).toBe(1);
38
32
  }
39
33
  });
40
34
 
41
- it("should not stdout and stderr when we call uuid with split false", async function () {
35
+ it("should not stdout and stderr when we call uuid with split false", async () => {
42
36
  // NB: Since we get run via npm run test, we know that npm bins are in our
43
37
  // PATH.
44
38
  const result = await spawnPromise("uuid", [], { split: false });
45
- expect(result.match(uuidRegex)).to.be.ok;
46
- });
47
- });
48
-
49
- describe("The spawnDetachedPromise method", function () {
50
- it("should return a uuid when we call uuid", async function () {
51
- // NB: Since we get run via npm run test, we know that npm bins are in our
52
- // PATH.
53
- const result = await spawnDetachedPromise("uuid", ["--help"]);
54
- expect(result.length > 10).to.be.ok;
39
+ expect(result.match(uuidRegex)).toBeTruthy();
55
40
  });
56
41
  });
57
42
 
@@ -85,81 +70,68 @@ function wrapSplitObservableInPromise(
85
70
  });
86
71
  }
87
72
 
88
- describe("The spawn method", function () {
89
- it("should return a disposable subscription", async function () {
73
+ describe("The spawn method", () => {
74
+ it("should return a disposable subscription", async () => {
90
75
  // this only check the unsubscribe goes w/o error, not that the spawned process is killed
91
76
  // (difficult to do that, maybe iterate through child processes and check ?)
92
77
  spawn("sleep", ["2"]).subscribe().unsubscribe();
93
78
  });
94
79
 
95
- it("should return split stderr in a inner tag when called with split", async function () {
80
+ it("should return split stderr in a inner tag when called with split", async () => {
96
81
  // provide an invalid param to uuid so it complains on stderr
97
- const rxSpawn: Observable<{ source: any; text: any }> = spawn(
98
- "uuid",
99
- ["foo"],
100
- { split: true },
101
- ) as any;
82
+ const rxSpawn: Observable<{ source: any; text: any }> = spawn("uuid", ["foo"], { split: true }) as any;
102
83
  const result = await wrapSplitObservableInPromise(rxSpawn);
103
- expect(result.stderr.length > 10).to.be.ok;
104
- expect(result.stdout).to.be.empty;
105
- expect(result.error).to.be.an("error");
84
+ expect(result.stderr.length > 10).toBeTruthy();
85
+ expect(result.stdout).toBe("");
86
+ expect(result.error).toBeInstanceOf(Error);
106
87
  });
107
88
 
108
- it("should return split stdout in a inner tag when called with split", async function () {
89
+ it("should return split stdout in a inner tag when called with split", async () => {
109
90
  const rxSpawn: Observable<{ source: any; text: any }> = spawn("uuid", [], {
110
91
  split: true,
111
92
  });
112
93
  const result = await wrapSplitObservableInPromise(rxSpawn);
113
- expect(result.stdout.match(uuidRegex)).to.be.ok;
114
- expect(result.stderr).to.be.empty;
115
- expect(result.error).to.be.undefined;
94
+ expect(result.stdout.match(uuidRegex)).toBeTruthy();
95
+ expect(result.stderr).toBe("");
96
+ expect(result.error).toBeUndefined();
116
97
  });
117
98
 
118
- it("should ignore stderr if options.stdio = ignore", async function () {
119
- const rxSpawn: Observable<{ source: any; text: any }> = spawn(
120
- "uuid",
121
- ["foo"],
122
- { split: true, stdio: [null, null, "ignore"] },
123
- );
99
+ it("should ignore stderr if options.stdio = ignore", async () => {
100
+ const rxSpawn: Observable<{ source: any; text: any }> = spawn("uuid", ["foo"], {
101
+ split: true,
102
+ stdio: [null, null, "ignore"],
103
+ });
124
104
  const result = await wrapSplitObservableInPromise(rxSpawn);
125
- expect(result.stderr).to.be.empty;
105
+ expect(result.stderr).toBe("");
126
106
  });
127
107
 
128
- it("should ignore stdout if options.stdio = inherit", async function () {
108
+ it("should ignore stdout if options.stdio = inherit", async () => {
129
109
  const rxSpawn: Observable<{ source: any; text: any }> = spawn("uuid", [], {
130
110
  split: true,
131
111
  stdio: [null, "inherit", null],
132
112
  });
133
113
  const result = await wrapSplitObservableInPromise(rxSpawn);
134
- expect(result.stdout).to.be.empty;
114
+ expect(result.stdout).toBe("");
135
115
  });
136
116
 
137
- it("should croak if stdin is provided but stdio.stdin is disabled", async function () {
117
+ it("should croak if stdin is provided but stdio.stdin is disabled", async () => {
138
118
  const stdin = of("a");
139
- const rxSpawn: Observable<{ source: any; text: any }> = spawn(
140
- "marked",
141
- [],
142
- {
143
- split: true,
144
- stdin: stdin,
145
- stdio: ["ignore", null, null],
146
- },
147
- );
119
+ const rxSpawn: Observable<{ source: any; text: any }> = spawn("marked", [], {
120
+ split: true,
121
+ stdin: stdin,
122
+ stdio: ["ignore", null, null],
123
+ });
148
124
  const result = await wrapSplitObservableInPromise(rxSpawn);
149
- expect(result.error).to.be.an("error");
125
+ expect(result.error).toBeInstanceOf(Error);
150
126
  });
151
127
 
152
- it("should subscribe to provided stdin", async function () {
128
+ it("should subscribe to provided stdin", async () => {
153
129
  const stdin = of("a");
154
- const rxSpawn: Observable<{ source: any; text: any }> = spawn(
155
- "marked",
156
- [],
157
- {
158
- split: true,
159
- stdin: stdin,
160
- },
161
- );
130
+ const rxSpawn: Observable<{ source: any; text: any }> = spawn("marked", [], {
131
+ split: true,
132
+ stdin: stdin,
133
+ });
162
134
  const result = await wrapSplitObservableInPromise(rxSpawn);
163
- expect(result.stdout.trim()).to.be.equal("<p>a</p>");
135
+ expect(result.stdout.trim()).toBe("<p>a</p>");
164
136
  });
165
137
  });
package/tsconfig.json CHANGED
@@ -21,5 +21,5 @@
21
21
  "indentSize": 2,
22
22
  "tabSize": 2
23
23
  },
24
- "exclude": ["node_modules", "lib"]
24
+ "exclude": ["node_modules", "lib", "test"]
25
25
  }
package/eslint.config.mjs DELETED
@@ -1,88 +0,0 @@
1
- import typescriptEslint from "@typescript-eslint/eslint-plugin";
2
- import prettier from "eslint-plugin-prettier";
3
- import tsParser from "@typescript-eslint/parser";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import js from "@eslint/js";
7
- import { FlatCompat } from "@eslint/eslintrc";
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
- const compat = new FlatCompat({
12
- baseDirectory: __dirname,
13
- recommendedConfig: js.configs.recommended,
14
- allConfig: js.configs.all,
15
- });
16
-
17
- export default [
18
- ...compat.extends(
19
- "eslint:recommended",
20
- "prettier",
21
- "plugin:@typescript-eslint/eslint-recommended",
22
- "plugin:@typescript-eslint/recommended",
23
- ),
24
- {
25
- files: ["./src/*.{ts,tsx}", "./test/*.{ts,tsx}"],
26
- plugins: {
27
- "@typescript-eslint": typescriptEslint,
28
- prettier,
29
- },
30
-
31
- languageOptions: {
32
- globals: {},
33
- parser: tsParser,
34
- ecmaVersion: 5,
35
- sourceType: "script",
36
-
37
- parserOptions: {
38
- project: "./tsconfig.json",
39
- },
40
- },
41
-
42
- rules: {
43
- "prettier/prettier": "warn",
44
-
45
- "spaced-comment": [
46
- "error",
47
- "always",
48
- {
49
- markers: ["/"],
50
- },
51
- ],
52
-
53
- "no-fallthrough": "error",
54
- "@typescript-eslint/ban-ts-comment": "warn",
55
-
56
- "@typescript-eslint/consistent-type-imports": [
57
- "error",
58
- {
59
- prefer: "type-imports",
60
- },
61
- ],
62
-
63
- "@typescript-eslint/no-inferrable-types": [
64
- "error",
65
- {
66
- ignoreParameters: false,
67
- ignoreProperties: false,
68
- },
69
- ],
70
-
71
- "@typescript-eslint/no-non-null-assertion": "off",
72
- "@typescript-eslint/no-floating-promises": "error",
73
-
74
- "@typescript-eslint/no-unused-vars": [
75
- "warn",
76
- {
77
- args: "after-used",
78
- argsIgnorePattern: "^_",
79
- varsIgnorePattern: "^_",
80
- ignoreRestSiblings: true,
81
- },
82
- ],
83
-
84
- "@typescript-eslint/no-empty-function": ["error"],
85
- "@typescript-eslint/restrict-template-expressions": "off",
86
- },
87
- },
88
- ];