soda-nodejs 0.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.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # soda-node
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/soda-node.svg?style=flat)](https://npmjs.org/package/soda-node)
4
+ [![NPM downloads](http://img.shields.io/npm/dm/soda-node.svg?style=flat)](https://npmjs.org/package/soda-node)
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ $ yarn install
10
+ ```
11
+
12
+ ```bash
13
+ $ npm run dev
14
+ $ npm run build
15
+ ```
16
+
17
+ ## Options
18
+
19
+ TODO
20
+
21
+ ## LICENSE
22
+
23
+ MIT
@@ -0,0 +1,41 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { ExecOptions, SpawnOptions, SpawnOptionsWithoutStdio, SpawnOptionsWithStdioTuple, StdioNull, StdioPipe } from "child_process";
5
+ import { ObjectEncodingOptions } from "fs";
6
+ export declare function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>;
7
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>;
8
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>;
9
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>;
10
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>;
11
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>;
12
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>;
13
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>;
14
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>;
15
+ export declare function spawnAsync(command: string, options: SpawnOptions): Promise<void>;
16
+ export declare function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>;
17
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>;
18
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>;
19
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>;
20
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>;
21
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>;
22
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>;
23
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>;
24
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>;
25
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>;
26
+ export type ExecResult<T> = {
27
+ stdout: T;
28
+ stderr: T;
29
+ };
30
+ export declare function execAsync(command: string): Promise<ExecResult<string>>;
31
+ export declare function execAsync(command: string, options: {
32
+ encoding: "buffer" | null;
33
+ } & ExecOptions): Promise<ExecResult<Buffer>>;
34
+ export declare function execAsync(command: string, options: {
35
+ encoding: BufferEncoding;
36
+ } & ExecOptions): Promise<ExecResult<string>>;
37
+ export declare function execAsync(command: string, options: {
38
+ encoding: BufferEncoding;
39
+ } & ExecOptions): Promise<ExecResult<string | Buffer>>;
40
+ export declare function execAsync(command: string, options: ExecOptions): Promise<ExecResult<string>>;
41
+ export declare function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<ExecResult<string | Buffer>>;
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ execAsync: () => execAsync,
23
+ spawnAsync: () => spawnAsync
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+ var import_child_process = require("child_process");
27
+ async function spawnAsync(command, args, options) {
28
+ await new Promise((resolve, reject) => {
29
+ const child = (0, import_child_process.spawn)(command, args, options);
30
+ child.on("exit", (code) => {
31
+ if (code !== 0) {
32
+ reject(new Error(`Command failed with code ${code}`));
33
+ return;
34
+ }
35
+ resolve();
36
+ });
37
+ });
38
+ }
39
+ async function execAsync(command, options) {
40
+ return await new Promise((resolve, reject) => {
41
+ (0, import_child_process.exec)(command, options, (error, stdout, stderr) => {
42
+ if (error) {
43
+ reject(error);
44
+ return;
45
+ }
46
+ resolve({ stdout, stderr });
47
+ });
48
+ });
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ execAsync,
53
+ spawnAsync
54
+ });
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["import { exec, ExecOptions, spawn, SpawnOptions, SpawnOptionsWithoutStdio, SpawnOptionsWithStdioTuple, StdioNull, StdioPipe } from \"child_process\"\r\nimport { ObjectEncodingOptions } from \"fs\"\r\n\r\nexport function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptions): Promise<void>\r\nexport function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>\r\nexport async function spawnAsync(command: string, args?: any, options?: any) {\r\n await new Promise<void>((resolve, reject) => {\r\n const child = spawn(command, args, options)\r\n child.on(\"exit\", code => {\r\n if (code !== 0) {\r\n reject(new Error(`Command failed with code ${code}`))\r\n return\r\n }\r\n resolve()\r\n })\r\n })\r\n}\r\n\r\nexport type ExecResult<T> = {\r\n stdout: T\r\n stderr: T\r\n}\r\n\r\nexport async function execAsync(command: string): Promise<ExecResult<string>>\r\nexport async function execAsync(command: string, options: { encoding: \"buffer\" | null } & ExecOptions): Promise<ExecResult<Buffer>>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<ExecResult<string>>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<ExecResult<string | Buffer>>\r\nexport async function execAsync(command: string, options: ExecOptions): Promise<ExecResult<string>>\r\nexport async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<ExecResult<string | Buffer>>\r\nexport async function execAsync(command: string, options?: any) {\r\n return await new Promise<ExecResult<string | Buffer>>((resolve, reject) => {\r\n exec(command, options, (error, stdout, stderr) => {\r\n if (error) {\r\n reject(error)\r\n return\r\n }\r\n resolve({ stdout, stderr })\r\n })\r\n })\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAmI;AAuBnI,eAAsB,WAAW,SAAiB,MAAY,SAAe;AACzE,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AACzC,UAAM,YAAQ,4BAAM,SAAS,MAAM,OAAO;AAC1C,UAAM,GAAG,QAAQ,UAAQ;AACrB,UAAI,SAAS,GAAG;AACZ,eAAO,IAAI,MAAM,4BAA4B,MAAM,CAAC;AACpD;AAAA,MACJ;AACA,cAAQ;AAAA,IACZ,CAAC;AAAA,EACL,CAAC;AACL;AAaA,eAAsB,UAAU,SAAiB,SAAe;AAC5D,SAAO,MAAM,IAAI,QAAqC,CAAC,SAAS,WAAW;AACvE,mCAAK,SAAS,SAAS,CAAC,OAAO,QAAQ,WAAW;AAC9C,UAAI,OAAO;AACP,eAAO,KAAK;AACZ;AAAA,MACJ;AACA,cAAQ,EAAE,QAAQ,OAAO,CAAC;AAAA,IAC9B,CAAC;AAAA,EACL,CAAC;AACL;",
6
+ "names": []
7
+ }
@@ -0,0 +1,41 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { ExecOptions, SpawnOptions, SpawnOptionsWithoutStdio, SpawnOptionsWithStdioTuple, StdioNull, StdioPipe } from "child_process";
5
+ import { ObjectEncodingOptions } from "fs";
6
+ export declare function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>;
7
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>;
8
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>;
9
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>;
10
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>;
11
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>;
12
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>;
13
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>;
14
+ export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>;
15
+ export declare function spawnAsync(command: string, options: SpawnOptions): Promise<void>;
16
+ export declare function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>;
17
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>;
18
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>;
19
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>;
20
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>;
21
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>;
22
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>;
23
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>;
24
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>;
25
+ export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>;
26
+ export type ExecResult<T> = {
27
+ stdout: T;
28
+ stderr: T;
29
+ };
30
+ export declare function execAsync(command: string): Promise<ExecResult<string>>;
31
+ export declare function execAsync(command: string, options: {
32
+ encoding: "buffer" | null;
33
+ } & ExecOptions): Promise<ExecResult<Buffer>>;
34
+ export declare function execAsync(command: string, options: {
35
+ encoding: BufferEncoding;
36
+ } & ExecOptions): Promise<ExecResult<string>>;
37
+ export declare function execAsync(command: string, options: {
38
+ encoding: BufferEncoding;
39
+ } & ExecOptions): Promise<ExecResult<string | Buffer>>;
40
+ export declare function execAsync(command: string, options: ExecOptions): Promise<ExecResult<string>>;
41
+ export declare function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<ExecResult<string | Buffer>>;
@@ -0,0 +1,28 @@
1
+ import { exec, spawn } from "child_process";
2
+ export async function spawnAsync(command, args, options) {
3
+ await new Promise((resolve, reject) => {
4
+ const child = spawn(command, args, options);
5
+ child.on("exit", code => {
6
+ if (code !== 0) {
7
+ reject(new Error(`Command failed with code ${code}`));
8
+ return;
9
+ }
10
+ resolve();
11
+ });
12
+ });
13
+ }
14
+ export async function execAsync(command, options) {
15
+ return await new Promise((resolve, reject) => {
16
+ exec(command, options, (error, stdout, stderr) => {
17
+ if (error) {
18
+ reject(error);
19
+ return;
20
+ }
21
+ resolve({
22
+ stdout,
23
+ stderr
24
+ });
25
+ });
26
+ });
27
+ }
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["exec","spawn","spawnAsync","command","args","options","Promise","resolve","reject","child","on","code","Error","execAsync","error","stdout","stderr"],"sources":["../../src/index.ts"],"sourcesContent":["import { exec, ExecOptions, spawn, SpawnOptions, SpawnOptionsWithoutStdio, SpawnOptionsWithStdioTuple, StdioNull, StdioPipe } from \"child_process\"\r\nimport { ObjectEncodingOptions } from \"fs\"\r\n\r\nexport function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, options: SpawnOptions): Promise<void>\r\nexport function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>\r\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>\r\nexport async function spawnAsync(command: string, args?: any, options?: any) {\r\n await new Promise<void>((resolve, reject) => {\r\n const child = spawn(command, args, options)\r\n child.on(\"exit\", code => {\r\n if (code !== 0) {\r\n reject(new Error(`Command failed with code ${code}`))\r\n return\r\n }\r\n resolve()\r\n })\r\n })\r\n}\r\n\r\nexport type ExecResult<T> = {\r\n stdout: T\r\n stderr: T\r\n}\r\n\r\nexport async function execAsync(command: string): Promise<ExecResult<string>>\r\nexport async function execAsync(command: string, options: { encoding: \"buffer\" | null } & ExecOptions): Promise<ExecResult<Buffer>>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<ExecResult<string>>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<ExecResult<string | Buffer>>\r\nexport async function execAsync(command: string, options: ExecOptions): Promise<ExecResult<string>>\r\nexport async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<ExecResult<string | Buffer>>\r\nexport async function execAsync(command: string, options?: any) {\r\n return await new Promise<ExecResult<string | Buffer>>((resolve, reject) => {\r\n exec(command, options, (error, stdout, stderr) => {\r\n if (error) {\r\n reject(error)\r\n return\r\n }\r\n resolve({ stdout, stderr })\r\n })\r\n })\r\n}\r\n"],"mappings":"AAAA,SAASA,IAAI,EAAeC,KAAK,QAAkG,eAAe;AAuBlJ,OAAO,eAAeC,UAAUA,CAACC,OAAe,EAAEC,IAAU,EAAEC,OAAa,EAAE;EACzE,MAAM,IAAIC,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IACzC,MAAMC,KAAK,GAAGR,KAAK,CAACE,OAAO,EAAEC,IAAI,EAAEC,OAAO,CAAC;IAC3CI,KAAK,CAACC,EAAE,CAAC,MAAM,EAAEC,IAAI,IAAI;MACrB,IAAIA,IAAI,KAAK,CAAC,EAAE;QACZH,MAAM,CAAC,IAAII,KAAK,CAAE,4BAA2BD,IAAK,EAAC,CAAC,CAAC;QACrD;MACJ;MACAJ,OAAO,CAAC,CAAC;IACb,CAAC,CAAC;EACN,CAAC,CAAC;AACN;AAaA,OAAO,eAAeM,SAASA,CAACV,OAAe,EAAEE,OAAa,EAAE;EAC5D,OAAO,MAAM,IAAIC,OAAO,CAA8B,CAACC,OAAO,EAAEC,MAAM,KAAK;IACvER,IAAI,CAACG,OAAO,EAAEE,OAAO,EAAE,CAACS,KAAK,EAAEC,MAAM,EAAEC,MAAM,KAAK;MAC9C,IAAIF,KAAK,EAAE;QACPN,MAAM,CAACM,KAAK,CAAC;QACb;MACJ;MACAP,OAAO,CAAC;QAAEQ,MAAM;QAAEC;MAAO,CAAC,CAAC;IAC/B,CAAC,CAAC;EACN,CAAC,CAAC;AACN"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "soda-nodejs",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "scripts": {
9
+ "dev": "father dev",
10
+ "build": "father build",
11
+ "build:deps": "father prebundle",
12
+ "prepublishOnly": "father doctor && npm run build"
13
+ },
14
+ "keywords": [],
15
+ "authors": [],
16
+ "license": "MIT",
17
+ "files": [
18
+ "compiled",
19
+ "dist",
20
+ "src"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/1adybug/soda-nodejs.git"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^20.11.30",
32
+ "father": "^4.4.0"
33
+ }
34
+ }
package/src/index.ts ADDED
@@ -0,0 +1,58 @@
1
+ import { exec, ExecOptions, spawn, SpawnOptions, SpawnOptionsWithoutStdio, SpawnOptionsWithStdioTuple, StdioNull, StdioPipe } from "child_process"
2
+ import { ObjectEncodingOptions } from "fs"
3
+
4
+ export function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): Promise<void>
5
+ export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>
6
+ export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>
7
+ export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>
8
+ export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>
9
+ export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>
10
+ export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>
11
+ export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>
12
+ export function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>
13
+ export function spawnAsync(command: string, options: SpawnOptions): Promise<void>
14
+ export function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): Promise<void>
15
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): Promise<void>
16
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): Promise<void>
17
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): Promise<void>
18
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): Promise<void>
19
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): Promise<void>
20
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): Promise<void>
21
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): Promise<void>
22
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): Promise<void>
23
+ export function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): Promise<void>
24
+ export async function spawnAsync(command: string, args?: any, options?: any) {
25
+ await new Promise<void>((resolve, reject) => {
26
+ const child = spawn(command, args, options)
27
+ child.on("exit", code => {
28
+ if (code !== 0) {
29
+ reject(new Error(`Command failed with code ${code}`))
30
+ return
31
+ }
32
+ resolve()
33
+ })
34
+ })
35
+ }
36
+
37
+ export type ExecResult<T> = {
38
+ stdout: T
39
+ stderr: T
40
+ }
41
+
42
+ export async function execAsync(command: string): Promise<ExecResult<string>>
43
+ export async function execAsync(command: string, options: { encoding: "buffer" | null } & ExecOptions): Promise<ExecResult<Buffer>>
44
+ export async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<ExecResult<string>>
45
+ export async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<ExecResult<string | Buffer>>
46
+ export async function execAsync(command: string, options: ExecOptions): Promise<ExecResult<string>>
47
+ export async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<ExecResult<string | Buffer>>
48
+ export async function execAsync(command: string, options?: any) {
49
+ return await new Promise<ExecResult<string | Buffer>>((resolve, reject) => {
50
+ exec(command, options, (error, stdout, stderr) => {
51
+ if (error) {
52
+ reject(error)
53
+ return
54
+ }
55
+ resolve({ stdout, stderr })
56
+ })
57
+ })
58
+ }