@node-cli/run 1.1.0 → 1.1.2

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 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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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/* 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 +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"],"rangeMappings":";;;;;;;;;;;;;;;;;;","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,CAAC,EAAEH,cAAcI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEN,MAAM,CAAC;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/* 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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/run",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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.1.0",
15
+ "execa": "9.5.1",
16
16
  "kleur": "4.1.5"
17
17
  },
18
18
  "scripts": {
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "c7a00537e6b35ea13ccbab724b30f45ad0e6a822"
34
+ "gitHead": "40e92aa4e7b59c7cda398529ef00cd0fab944644"
35
35
  }