@node-cli/run 1.0.3 → 1.0.5
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/dist/run.js.map +1 -1
- package/package.json +4 -4
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run.ts"],"sourcesContent":["import { execaCommand } from \"execa\";\nimport kleur from \"kleur\";\n\n/**\n * Runs a shell command asynchronously and\n * returns both `stdout` and `stderr`.\n * If the command fails to run (invalid command or the commands status is\n * anything but 0), the call will throw an exception. The exception can be\n * ignored if the `options.ignoreError` flag is true.\n *\n * @async\n */\nexport type RunResult = {\n\tstderr?: string | number;\n\tstdout?: string | number;\n\texitCode?: number;\n\tshortMessage?: string;\n};\nexport const run = async (\n\tcommand: string,\n\toptions?: { ignoreError?: boolean },\n): Promise<RunResult> => {\n\tconst { ignoreError } = {\n\t\tignoreError: false,\n\t\t...options,\n\t};\n\ttry {\n\t\tconst { stdout, stderr } = await execaCommand(command, {\n\t\t\t/**\n\t\t\t * For some reason, a command with a \" or ' in execa.command() will\n\t\t\t * fail, but it works if shell is set to true... It would work if\n\t\t\t * the execaCommand() API is not used:\n\t\t\t * execa(\"ls\", [\"-l\", \"|\", \"wc\"]);\n\t\t\t * Same problems with &, &&, | and ||.\n\t\t\t */\n\t\t\tshell:\n\t\t\t\tcommand.includes('\"') ||\n\t\t\t\tcommand.includes(\"'\") ||\n\t\t\t\tcommand.includes(\"&&\") ||\n\t\t\t\tcommand.includes(\"&\") ||\n\t\t\t\tcommand.includes(\"||\") ||\n\t\t\t\tcommand.includes(\"|\"),\n\t\t});\n\n\t\treturn { stderr, stdout };\n\t} catch (error) {\n\t\tif (ignoreError) {\n\t\t\treturn {\n\t\t\t\texitCode: error.exitCode === undefined ? 1 : error.exitCode,\n\t\t\t\tshortMessage: error.shortMessage,\n\t\t\t\tstderr: error.exitCode === undefined ? 1 : error.exitCode,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(kleur.red(error));\n\t\t}\n\t}\n};\n"],"names":["execaCommand","kleur","run","command","options","ignoreError","stdout","stderr","shell","includes","error","exitCode","undefined","shortMessage","Error","red"],"mappings":"AAAA,SAASA,YAAY,QAAQ,QAAQ;AACrC,OAAOC,WAAW,QAAQ;AAiB1B,OAAO,MAAMC,MAAM,OAClBC,SACAC;IAEA,MAAM,EAAEC,WAAW,EAAE,GAAG;QACvBA,aAAa;QACb,GAAGD,OAAO;IACX;IACA,IAAI;QACH,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMP,aAAaG,SAAS;YACtD;;;;;;IAMC,GACDK,OACCL,QAAQM,QAAQ,CAAC,QACjBN,QAAQM,QAAQ,CAAC,QACjBN,QAAQM,QAAQ,CAAC,SACjBN,QAAQM,QAAQ,CAAC,QACjBN,QAAQM,QAAQ,CAAC,SACjBN,QAAQM,QAAQ,CAAC;QACnB;QAEA,OAAO;YAAEF;YAAQD;QAAO;IACzB,EAAE,OAAOI,OAAO;QACf,IAAIL,aAAa;YAChB,OAAO;gBACNM,UAAUD,MAAMC,QAAQ,KAAKC,YAAY,IAAIF,MAAMC,QAAQ;gBAC3DE,cAAcH,MAAMG,YAAY;gBAChCN,QAAQG,MAAMC,QAAQ,KAAKC,YAAY,IAAIF,MAAMC,QAAQ;YAC1D;QACD,OAAO;YACN,MAAM,IAAIG,MAAMb,MAAMc,GAAG,CAACL;QAC3B;IACD;AACD,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/run.ts"],"sourcesContent":["import { execaCommand } from \"execa\";\nimport kleur from \"kleur\";\n\n/**\n * Runs a shell command asynchronously and\n * returns both `stdout` and `stderr`.\n * If the command fails to run (invalid command or the commands status is\n * anything but 0), the call will throw an exception. The exception can be\n * ignored if the `options.ignoreError` flag is true.\n *\n * @async\n */\nexport type RunResult = {\n\tstderr?: string | number;\n\tstdout?: string | number;\n\texitCode?: number;\n\tshortMessage?: string;\n};\nexport const run = async (\n\tcommand: string,\n\toptions?: { ignoreError?: boolean },\n): Promise<RunResult> => {\n\tconst { ignoreError } = {\n\t\tignoreError: false,\n\t\t...options,\n\t};\n\ttry {\n\t\tconst { stdout, stderr } = await execaCommand(command, {\n\t\t\t/**\n\t\t\t * For some reason, a command with a \" or ' in execa.command() will\n\t\t\t * fail, but it works if shell is set to true... It would work if\n\t\t\t * the execaCommand() API is not used:\n\t\t\t * execa(\"ls\", [\"-l\", \"|\", \"wc\"]);\n\t\t\t * Same problems with &, &&, | and ||.\n\t\t\t */\n\t\t\tshell:\n\t\t\t\tcommand.includes('\"') ||\n\t\t\t\tcommand.includes(\"'\") ||\n\t\t\t\tcommand.includes(\"&&\") ||\n\t\t\t\tcommand.includes(\"&\") ||\n\t\t\t\tcommand.includes(\"||\") ||\n\t\t\t\tcommand.includes(\"|\"),\n\t\t});\n\n\t\treturn { stderr, stdout };\n\t} catch (error) {\n\t\tif (ignoreError) {\n\t\t\treturn {\n\t\t\t\texitCode: error.exitCode === undefined ? 1 : error.exitCode,\n\t\t\t\tshortMessage: error.shortMessage,\n\t\t\t\tstderr: error.exitCode === undefined ? 1 : error.exitCode,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(kleur.red(error));\n\t\t}\n\t}\n};\n"],"names":["execaCommand","kleur","run","command","options","ignoreError","stdout","stderr","shell","includes","error","exitCode","undefined","shortMessage","Error","red"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,YAAY,QAAQ,QAAQ;AACrC,OAAOC,WAAW,QAAQ;AAiB1B,OAAO,MAAMC,MAAM,OAClBC,SACAC;IAEA,MAAM,EAAEC,WAAW,EAAE,GAAG;QACvBA,aAAa;QACb,GAAGD,OAAO;IACX;IACA,IAAI;QACH,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMP,aAAaG,SAAS;YACtD;;;;;;IAMC,GACDK,OACCL,QAAQM,QAAQ,CAAC,QACjBN,QAAQM,QAAQ,CAAC,QACjBN,QAAQM,QAAQ,CAAC,SACjBN,QAAQM,QAAQ,CAAC,QACjBN,QAAQM,QAAQ,CAAC,SACjBN,QAAQM,QAAQ,CAAC;QACnB;QAEA,OAAO;YAAEF;YAAQD;QAAO;IACzB,EAAE,OAAOI,OAAO;QACf,IAAIL,aAAa;YAChB,OAAO;gBACNM,UAAUD,MAAMC,QAAQ,KAAKC,YAAY,IAAIF,MAAMC,QAAQ;gBAC3DE,cAAcH,MAAMG,YAAY;gBAChCN,QAAQG,MAAMC,QAAQ,KAAKC,YAAY,IAAIF,MAAMC,QAAQ;YAC1D;QACD,OAAO;YACN,MAAM,IAAIG,MAAMb,MAAMc,GAAG,CAACL;QAC3B;IACD;AACD,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/run",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "A wrapper for child_process for nodejs CLI apps",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"node": ">=16",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"execa": "
|
|
15
|
+
"execa": "9.1.0",
|
|
16
16
|
"kleur": "4.1.5"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"build:js": "swc --strip-leading-paths --source-maps --out-dir dist src",
|
|
22
22
|
"build:types": "tsc",
|
|
23
23
|
"clean": "rimraf dist types coverage",
|
|
24
|
-
"lint": "
|
|
24
|
+
"lint": "biome lint src",
|
|
25
25
|
"test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules jest",
|
|
26
26
|
"test:coverage": "npm run test -- --coverage",
|
|
27
27
|
"watch": "swc --strip-leading-paths --watch --out-dir dist src"
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "e511453b89f180c52ca60e10bd1dfb3c8675cbec"
|
|
33
33
|
}
|