cli-argv-util 1.2.2 → 1.2.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
@@ -69,7 +69,7 @@ See the **TypeScript Declarations** at the top of [cli-argv-util.ts](cli-argv-ut
69
69
  <br>
70
70
 
71
71
  ---
72
- **CLI Build Tools**
72
+ **CLI Build Tools for package.json**
73
73
  - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
74
74
  - 📄 [cli-argv-util](https://github.com/center-key/cli-argv-util):&nbsp; _Copy or rename a file with optional package version number_
75
75
  - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):&nbsp; _Recursively copy files from one folder to another folder_
@@ -1,4 +1,4 @@
1
- //! cli-argv-util v1.2.2 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
1
+ //! cli-argv-util v1.2.3 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
2
2
 
3
3
  export type StringFlagMap = {
4
4
  [flag: string]: string | undefined;
@@ -1,4 +1,4 @@
1
- //! cli-argv-util v1.2.2 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
1
+ //! cli-argv-util v1.2.3 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
2
2
 
3
3
  import { execSync } from 'node:child_process';
4
4
  import fs from 'fs';
@@ -8,7 +8,17 @@ const cliArgvUtil = {
8
8
  const toCamel = (token) => token.replace(/-./g, char => char[1].toUpperCase());
9
9
  const toEntry = (pair) => [toCamel(pair[0]), pair[1]];
10
10
  const toPair = (flag) => flag.replace(/^--/, '').split('=');
11
- const args = process.argv.slice(2);
11
+ const unquote = (builder, nextArg) => {
12
+ const arg = nextArg.replace(/^'/, '').replace(/'$/, '');
13
+ const last = builder[1].length - 1;
14
+ if (builder[0])
15
+ builder[1][last] = builder[1][last] + ' ' + arg;
16
+ else
17
+ builder[1].push(arg);
18
+ const quoteMode = (/^'/.test(nextArg) || builder[0]) && !/'$/.test(nextArg);
19
+ return [quoteMode, builder[1]];
20
+ };
21
+ const args = process.argv.slice(2).reduce(unquote, [false, []])[1];
12
22
  const pairs = args.filter(arg => /^--/.test(arg)).map(toPair);
13
23
  const flagMap = Object.fromEntries(pairs.map(toEntry));
14
24
  const onEntries = validFlags.map(flag => [toCamel(flag), toCamel(flag) in flagMap]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-argv-util",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Simple utility to parse command line parameters and flags (arguments vector)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -77,17 +77,17 @@
77
77
  "slash": "~5.1"
78
78
  },
79
79
  "devDependencies": {
80
- "@types/node": "~20.5",
81
- "@typescript-eslint/eslint-plugin": "~6.4",
82
- "@typescript-eslint/parser": "~6.4",
83
- "add-dist-header": "~1.2",
80
+ "@types/node": "~20.6",
81
+ "@typescript-eslint/eslint-plugin": "~6.7",
82
+ "@typescript-eslint/parser": "~6.7",
83
+ "add-dist-header": "~1.3",
84
84
  "assert-deep-strict-equal": "~1.1",
85
85
  "copy-file-util": "~1.1",
86
- "eslint": "~8.47",
86
+ "eslint": "~8.50",
87
87
  "jshint": "~2.13",
88
88
  "mocha": "~10.2",
89
89
  "rimraf": "~5.0",
90
90
  "run-scripts-util": "~1.2",
91
- "typescript": "~5.1"
91
+ "typescript": "~5.2"
92
92
  }
93
93
  }