@rcompat/io 0.4.0 → 0.5.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,6 +1,6 @@
1
- declare namespace _default {
2
- export { Context };
3
- }
4
- export default _default;
5
1
  import Context from "#async/Context";
2
+ declare const _default: {
3
+ Context: typeof Context;
4
+ };
5
+ export default _default;
6
6
  //# sourceMappingURL=async.d.ts.map
@@ -4,7 +4,9 @@ declare const _default: {
4
4
  };
5
5
  isatty: () => boolean;
6
6
  run: (command: string, options?: import("node:child_process").ExecOptions) => Promise<string>;
7
- spawn: (command: string, options: import("node:child_process").SpawnOptions) => {
7
+ spawn: (command: string, options?: import("node:child_process").SpawnOptions & {
8
+ inherit?: boolean;
9
+ }) => Promise<void> | {
8
10
  stderr: import("node:stream/web").ReadableStream<any>;
9
11
  stdin: import("node:stream/web").WritableStream<any>;
10
12
  stdout: import("node:stream/web").ReadableStream<any>;
@@ -1,5 +1,8 @@
1
1
  import { type SpawnOptions } from "node:child_process";
2
- declare const _default: (command: string, options: SpawnOptions) => {
2
+ type Options = SpawnOptions & {
3
+ inherit?: boolean;
4
+ };
5
+ declare const _default: (command: string, options?: Options) => Promise<void> | {
3
6
  stderr: import("node:stream/web").ReadableStream<any>;
4
7
  stdin: import("node:stream/web").WritableStream<any>;
5
8
  stdout: import("node:stream/web").ReadableStream<any>;
@@ -1,6 +1,15 @@
1
+ import assert from "@rcompat/assert";
1
2
  import { spawn } from "node:child_process";
2
3
  import { Readable, Writable } from "node:stream";
3
4
  export default (command, options) => {
5
+ assert.maybe.dict(options);
6
+ const inherit = assert.maybe.boolean(options?.inherit) ?? false;
7
+ if (inherit) {
8
+ return new Promise((resolve, reject) => {
9
+ const child = spawn(command, { ...options, shell: true, stdio: "inherit" });
10
+ child.on("exit", code => code === 0 ? resolve() : reject(code));
11
+ });
12
+ }
4
13
  const { stderr, stdin, stdout } = spawn(command, {
5
14
  ...options,
6
15
  shell: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcompat/io",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Standard library input/output",
5
5
  "bugs": "https://github.com/rcompat/rcompat/issues",
6
6
  "license": "MIT",
@@ -14,22 +14,25 @@
14
14
  "url": "https://github.com/rcompat/rcompat",
15
15
  "directory": "packages/io"
16
16
  },
17
+ "dependencies": {
18
+ "@rcompat/assert": "^0.8.0"
19
+ },
17
20
  "type": "module",
18
21
  "imports": {
19
22
  "#*": {
20
- "apekit": "./src/private/*.ts",
23
+ "source": "./src/private/*.ts",
21
24
  "default": "./lib/private/*.js"
22
25
  }
23
26
  },
24
27
  "exports": {
25
28
  ".": {
26
- "apekit": "./src/public/index.ts",
29
+ "source": "./src/public/index.ts",
27
30
  "default": "./lib/public/index.js"
28
31
  }
29
32
  },
30
33
  "scripts": {
31
34
  "build": "npm run clean && tsc",
32
- "test": "npm run build && npx proby",
35
+ "test": "npx proby",
33
36
  "clean": "rm -rf ./lib"
34
37
  }
35
38
  }