@node-cli/run 1.1.4 → 1.1.6
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 +2 -2
- package/dist/run.js.map +1 -1
- package/package.json +6 -6
package/dist/run.js
CHANGED
|
@@ -13,13 +13,13 @@ export const run = async (command, options)=>{
|
|
|
13
13
|
if (command.includes("&&") || command.includes("&") || command.includes("||") || command.includes("|")) {
|
|
14
14
|
execaOptions.shell = true;
|
|
15
15
|
}
|
|
16
|
-
/* v8 ignore
|
|
16
|
+
/* v8 ignore start */ if (options?.streamOutput) {
|
|
17
17
|
execaOptions.stdout = [
|
|
18
18
|
"pipe",
|
|
19
19
|
"inherit"
|
|
20
20
|
];
|
|
21
21
|
}
|
|
22
|
-
try {
|
|
22
|
+
/* v8 ignore stop */ try {
|
|
23
23
|
if (execaOptions.shell) {
|
|
24
24
|
const { stdout, stderr } = await execaCommand(command, execaOptions);
|
|
25
25
|
return {
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run.ts"],"sourcesContent":["import { execa, execaCommand } from \"execa\";\nimport kleur from \"kleur\";\nimport { parseCommandString } from \"./utilities.js\";\n\n/**\n * Runs a shell command asynchronously and 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 *\n */\nexport type RunResult = {\n\tstderr?: string | number;\n\tstdout?: string | number;\n\texitCode?: number;\n\tshortMessage?: string;\n};\nexport type RunOptions = {\n\tignoreError?: boolean;\n\tstreamOutput?: boolean;\n};\ntype ExecaOptions = {\n\tpreferLocal: boolean;\n\tshell: boolean;\n\tstdout?: [\"pipe\", \"inherit\"];\n};\n\nexport const run = async (\n\tcommand: string,\n\toptions?: RunOptions,\n): Promise<RunResult> => {\n\tconst { ignoreError } = {\n\t\tignoreError: false,\n\t\t...options,\n\t};\n\tconst execaOptions: ExecaOptions = {\n\t\tshell: false,\n\t\tpreferLocal: true,\n\t};\n\n\tif (\n\t\tcommand.includes(\"&&\") ||\n\t\tcommand.includes(\"&\") ||\n\t\tcommand.includes(\"||\") ||\n\t\tcommand.includes(\"|\")\n\t) {\n\t\texecaOptions.shell = true;\n\t}\n\n\t/* v8 ignore
|
|
1
|
+
{"version":3,"sources":["../src/run.ts"],"sourcesContent":["import { execa, execaCommand } from \"execa\";\nimport kleur from \"kleur\";\nimport { parseCommandString } from \"./utilities.js\";\n\n/**\n * Runs a shell command asynchronously and 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 *\n */\nexport type RunResult = {\n\tstderr?: string | number;\n\tstdout?: string | number;\n\texitCode?: number;\n\tshortMessage?: string;\n};\nexport type RunOptions = {\n\tignoreError?: boolean;\n\tstreamOutput?: boolean;\n};\ntype ExecaOptions = {\n\tpreferLocal: boolean;\n\tshell: boolean;\n\tstdout?: [\"pipe\", \"inherit\"];\n};\n\nexport const run = async (\n\tcommand: string,\n\toptions?: RunOptions,\n): Promise<RunResult> => {\n\tconst { ignoreError } = {\n\t\tignoreError: false,\n\t\t...options,\n\t};\n\tconst execaOptions: ExecaOptions = {\n\t\tshell: false,\n\t\tpreferLocal: true,\n\t};\n\n\tif (\n\t\tcommand.includes(\"&&\") ||\n\t\tcommand.includes(\"&\") ||\n\t\tcommand.includes(\"||\") ||\n\t\tcommand.includes(\"|\")\n\t) {\n\t\texecaOptions.shell = true;\n\t}\n\n\t/* v8 ignore start */\n\tif (options?.streamOutput) {\n\t\texecaOptions.stdout = [\"pipe\", \"inherit\"];\n\t}\n\t/* v8 ignore stop */\n\n\ttry {\n\t\tif (execaOptions.shell) {\n\t\t\tconst { stdout, stderr } = await execaCommand(command, execaOptions);\n\t\t\treturn { stderr, stdout };\n\t\t} else {\n\t\t\tconst commandArray = parseCommandString(command);\n\t\t\tconst { stdout, stderr } = await execa(\n\t\t\t\tcommandArray[0],\n\t\t\t\tcommandArray.slice(1),\n\t\t\t\texecaOptions,\n\t\t\t);\n\t\t\treturn { stderr, stdout };\n\t\t}\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":["execa","execaCommand","kleur","parseCommandString","run","command","options","ignoreError","execaOptions","shell","preferLocal","includes","streamOutput","stdout","stderr","commandArray","slice","error","exitCode","undefined","shortMessage","Error","red"],"mappings":"AAAA,SAASA,KAAK,EAAEC,YAAY,QAAQ,QAAQ;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,SAASC,kBAAkB,QAAQ,iBAAiB;AA2BpD,OAAO,MAAMC,MAAM,OAClBC,SACAC;IAEA,MAAM,EAAEC,WAAW,EAAE,GAAG;QACvBA,aAAa;QACb,GAAGD,OAAO;IACX;IACA,MAAME,eAA6B;QAClCC,OAAO;QACPC,aAAa;IACd;IAEA,IACCL,QAAQM,QAAQ,CAAC,SACjBN,QAAQM,QAAQ,CAAC,QACjBN,QAAQM,QAAQ,CAAC,SACjBN,QAAQM,QAAQ,CAAC,MAChB;QACDH,aAAaC,KAAK,GAAG;IACtB;IAEA,mBAAmB,GACnB,IAAIH,SAASM,cAAc;QAC1BJ,aAAaK,MAAM,GAAG;YAAC;YAAQ;SAAU;IAC1C;IACA,kBAAkB,GAElB,IAAI;QACH,IAAIL,aAAaC,KAAK,EAAE;YACvB,MAAM,EAAEI,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMb,aAAaI,SAASG;YACvD,OAAO;gBAAEM;gBAAQD;YAAO;QACzB,OAAO;YACN,MAAME,eAAeZ,mBAAmBE;YACxC,MAAM,EAAEQ,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMd,MAChCe,YAAY,CAAC,EAAE,EACfA,aAAaC,KAAK,CAAC,IACnBR;YAED,OAAO;gBAAEM;gBAAQD;YAAO;QACzB;IACD,EAAE,OAAOI,OAAO;QACf,IAAIV,aAAa;YAChB,OAAO;gBACNW,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,MAAMnB,MAAMoB,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.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "A wrapper for child_process for nodejs CLI apps",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"node": ">=16",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"execa": "9.6.
|
|
16
|
+
"execa": "9.6.1",
|
|
17
17
|
"kleur": "4.1.5"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@node-cli/comments": "0.2.
|
|
39
|
-
"@vitest/coverage-v8": "
|
|
40
|
-
"vitest": "
|
|
38
|
+
"@node-cli/comments": "0.2.9",
|
|
39
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
40
|
+
"vitest": "4.0.18"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "06236497427f489176837d5f8274a3b2a4d4cf0d"
|
|
43
43
|
}
|