@node-cli/run 1.0.1 → 1.0.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/README.md CHANGED
@@ -53,3 +53,7 @@ const { exitCode, shortMessage } = await runCommand("ls /not-a-folder", {
53
53
  });
54
54
  // -> exitCode is 1 and shortMessage is "Command failed with exit code 1: ls /not-a-folder"
55
55
  ```
56
+
57
+ ## License
58
+
59
+ MIT © Arno Versini
package/dist/run.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { execaCommand } from "execa";
2
2
  import kleur from "kleur";
3
3
  export const run = async (command, options)=>{
4
- const { ignoreError } = {
4
+ const { ignoreError } = {
5
5
  ignoreError: false,
6
6
  ...options
7
7
  };
8
8
  try {
9
- const { stdout , stderr } = await execaCommand(command, {
9
+ const { stdout, stderr } = await execaCommand(command, {
10
10
  /**
11
11
  * For some reason, a command with a " or ' in execa.command() will
12
12
  * fail, but it works if shell is set to true... It would work if
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,YAAW,EAAE,GAAG;QACvBA,aAAa;QACb,GAAGD,OAAO;IACX;IACA,IAAI;QACH,MAAM,EAAEE,OAAM,EAAEC,OAAM,EAAE,GAAG,MAAMP,aAAaG,SAAS;YACtD;;;;;;IAMC,GACDK,OACCL,QAAQM,SAAS,QACjBN,QAAQM,SAAS,QACjBN,QAAQM,SAAS,SACjBN,QAAQM,SAAS,QACjBN,QAAQM,SAAS,SACjBN,QAAQM,SAAS;QACnB;QAEA,OAAO;YAAEF;YAAQD;QAAO;IACzB,EAAE,OAAOI,OAAO;QACf,IAAIL,aAAa;YAChB,OAAO;gBACNM,UAAUD,MAAMC,aAAaC,YAAY,IAAIF,MAAMC;gBACnDE,cAAcH,MAAMG;gBACpBN,QAAQG,MAAMC,aAAaC,YAAY,IAAIF,MAAMC;YAClD;QACD,OAAO;YACN,MAAM,IAAIG,MAAMb,MAAMc,IAAIL;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"],"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.1",
3
+ "version": "1.0.3",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "description": "A wrapper for child_process for nodejs CLI apps",
@@ -12,22 +12,22 @@
12
12
  ],
13
13
  "node": ">=16",
14
14
  "dependencies": {
15
- "execa": "7.1.1",
15
+ "execa": "8.0.1",
16
16
  "kleur": "4.1.5"
17
17
  },
18
18
  "scripts": {
19
- "build": "yarn run clean && yarn run build:types && yarn run build:js && yarn run build:barrel",
19
+ "build": "npm-run-all --serial clean build:types build:js build:barrel",
20
20
  "build:barrel": "barrelsby --delete --directory dist --pattern \"**/*.d.ts\" --name \"index.d\"",
21
- "build:js": "swc --source-maps --out-dir dist src",
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
24
  "lint": "prettier --write \"src/*.ts\" && eslint --fix \"src/*.ts\"",
25
25
  "test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules jest",
26
26
  "test:coverage": "npm run test -- --coverage",
27
- "watch": "swc --watch --out-dir dist src"
27
+ "watch": "swc --strip-leading-paths --watch --out-dir dist src"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "gitHead": "2e74543c37e77ca482acc9fda6d8716bc634e722"
32
+ "gitHead": "4205e6c82a1dee6f83f5b9f45d0ea878490287eb"
33
33
  }