@node-cli/run 1.1.2 → 1.1.3

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 CHANGED
@@ -13,7 +13,7 @@ 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
- /* istanbul ignore next */ if (options?.streamOutput) {
16
+ /* v8 ignore next 3 */ if (options?.streamOutput) {
17
17
  execaOptions.stdout = [
18
18
  "pipe",
19
19
  "inherit"
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\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 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/* istanbul ignore next */\n\tif (options?.streamOutput) {\n\t\texecaOptions.stdout = [\"pipe\", \"inherit\"];\n\t}\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,wBAAwB,GACxB,IAAIH,SAASM,cAAc;QAC1BJ,aAAaK,MAAM,GAAG;YAAC;YAAQ;SAAU;IAC1C;IAEA,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"}
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\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 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 next 3 */\n\tif (options?.streamOutput) {\n\t\texecaOptions.stdout = [\"pipe\", \"inherit\"];\n\t}\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,oBAAoB,GACpB,IAAIH,SAASM,cAAc;QAC1BJ,aAAaK,MAAM,GAAG;YAAC;YAAQ;SAAU;IAC1C;IAEA,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/dist/utilities.js CHANGED
@@ -8,7 +8,7 @@ export const parseCommandString = (command)=>{
8
8
  for (const token of trimmedCommand.split(SPACES_REGEXP)){
9
9
  // Allow spaces to be escaped by a backslash if not meant as a delimiter
10
10
  const previousToken = tokens.at(-1);
11
- /* istanbul ignore next */ if (previousToken && previousToken.endsWith("\\")) {
11
+ /* v8 ignore next 4 */ if (previousToken && previousToken.endsWith("\\")) {
12
12
  // Merge previous token with current one
13
13
  tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
14
14
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["const SPACES_REGEXP = / +/g;\n\nexport const parseCommandString = (command: string) => {\n\tconst trimmedCommand = command.trim();\n\tif (trimmedCommand === \"\") {\n\t\treturn [];\n\t}\n\tconst tokens = [];\n\tfor (const token of trimmedCommand.split(SPACES_REGEXP)) {\n\t\t// Allow spaces to be escaped by a backslash if not meant as a delimiter\n\t\tconst previousToken = tokens.at(-1);\n\t\t/* istanbul ignore next */\n\t\tif (previousToken && previousToken.endsWith(\"\\\\\")) {\n\t\t\t// Merge previous token with current one\n\t\t\ttokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;\n\t\t} else {\n\t\t\ttokens.push(token);\n\t\t}\n\t}\n\treturn tokens;\n};\n"],"names":["SPACES_REGEXP","parseCommandString","command","trimmedCommand","trim","tokens","token","split","previousToken","at","endsWith","length","slice","push"],"mappings":"AAAA,MAAMA,gBAAgB;AAEtB,OAAO,MAAMC,qBAAqB,CAACC;IAClC,MAAMC,iBAAiBD,QAAQE,IAAI;IACnC,IAAID,mBAAmB,IAAI;QAC1B,OAAO,EAAE;IACV;IACA,MAAME,SAAS,EAAE;IACjB,KAAK,MAAMC,SAASH,eAAeI,KAAK,CAACP,eAAgB;QACxD,wEAAwE;QACxE,MAAMQ,gBAAgBH,OAAOI,EAAE,CAAC,CAAC;QACjC,wBAAwB,GACxB,IAAID,iBAAiBA,cAAcE,QAAQ,CAAC,OAAO;YAClD,wCAAwC;YACxCL,MAAM,CAACA,OAAOM,MAAM,GAAG,EAAE,GAAG,GAAGH,cAAcI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEN,OAAO;QACrE,OAAO;YACND,OAAOQ,IAAI,CAACP;QACb;IACD;IACA,OAAOD;AACR,EAAE"}
1
+ {"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["const SPACES_REGEXP = / +/g;\n\nexport const parseCommandString = (command: string) => {\n\tconst trimmedCommand = command.trim();\n\tif (trimmedCommand === \"\") {\n\t\treturn [];\n\t}\n\tconst tokens = [];\n\tfor (const token of trimmedCommand.split(SPACES_REGEXP)) {\n\t\t// Allow spaces to be escaped by a backslash if not meant as a delimiter\n\t\tconst previousToken = tokens.at(-1);\n\t\t/* v8 ignore next 4 */\n\t\tif (previousToken && previousToken.endsWith(\"\\\\\")) {\n\t\t\t// Merge previous token with current one\n\t\t\ttokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;\n\t\t} else {\n\t\t\ttokens.push(token);\n\t\t}\n\t}\n\treturn tokens;\n};\n"],"names":["SPACES_REGEXP","parseCommandString","command","trimmedCommand","trim","tokens","token","split","previousToken","at","endsWith","length","slice","push"],"mappings":"AAAA,MAAMA,gBAAgB;AAEtB,OAAO,MAAMC,qBAAqB,CAACC;IAClC,MAAMC,iBAAiBD,QAAQE,IAAI;IACnC,IAAID,mBAAmB,IAAI;QAC1B,OAAO,EAAE;IACV;IACA,MAAME,SAAS,EAAE;IACjB,KAAK,MAAMC,SAASH,eAAeI,KAAK,CAACP,eAAgB;QACxD,wEAAwE;QACxE,MAAMQ,gBAAgBH,OAAOI,EAAE,CAAC,CAAC;QACjC,oBAAoB,GACpB,IAAID,iBAAiBA,cAAcE,QAAQ,CAAC,OAAO;YAClD,wCAAwC;YACxCL,MAAM,CAACA,OAAOM,MAAM,GAAG,EAAE,GAAG,GAAGH,cAAcI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEN,OAAO;QACrE,OAAO;YACND,OAAOQ,IAAI,CAACP;QACb;IACD;IACA,OAAOD;AACR,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/run",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
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": "9.5.1",
15
+ "execa": "9.6.0",
16
16
  "kleur": "4.1.5"
17
17
  },
18
18
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  "build:types": "tsc",
23
23
  "clean": "rimraf dist types coverage",
24
24
  "lint": "biome lint src",
25
- "test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules jest",
26
- "test:coverage": "npm run test -- --coverage",
25
+ "test": "vitest run --globals",
26
+ "test:coverage": "vitest run --coverage --globals",
27
27
  "test:echo": "echo \"testing testing\"",
28
28
  "test:watch": "npm run test -- --watch",
29
29
  "watch": "swc --strip-leading-paths --watch --out-dir dist src"
@@ -31,5 +31,9 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "40e92aa4e7b59c7cda398529ef00cd0fab944644"
34
+ "devDependencies": {
35
+ "@vitest/coverage-v8": "3.2.4",
36
+ "vitest": "3.2.4"
37
+ },
38
+ "gitHead": "2cef8f88aa5316a1789caad2bd7327ca908ccb9f"
35
39
  }