Skip to content

Commit

Permalink
Release v1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Sep 23, 2023
1 parent dd528e7 commit c45a0f4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ See the **TypeScript Declarations** at the top of [cli-argv-util.ts](cli-argv-ut
<br>

---
**CLI Build Tools**
**CLI Build Tools for package.json**
- 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
- 📄 [cli-argv-util](https://github.com/center-key/cli-argv-util):&nbsp; _Copy or rename a file with optional package version number_
- 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):&nbsp; _Recursively copy files from one folder to another folder_
Expand Down
2 changes: 1 addition & 1 deletion dist/cli-argv-util.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! cli-argv-util v1.2.2 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
//! cli-argv-util v1.2.3 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License

export type StringFlagMap = {
[flag: string]: string | undefined;
Expand Down
14 changes: 12 additions & 2 deletions dist/cli-argv-util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! cli-argv-util v1.2.2 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
//! cli-argv-util v1.2.3 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License

import { execSync } from 'node:child_process';
import fs from 'fs';
Expand All @@ -8,7 +8,17 @@ const cliArgvUtil = {
const toCamel = (token) => token.replace(/-./g, char => char[1].toUpperCase());
const toEntry = (pair) => [toCamel(pair[0]), pair[1]];
const toPair = (flag) => flag.replace(/^--/, '').split('=');
const args = process.argv.slice(2);
const unquote = (builder, nextArg) => {
const arg = nextArg.replace(/^'/, '').replace(/'$/, '');
const last = builder[1].length - 1;
if (builder[0])
builder[1][last] = builder[1][last] + ' ' + arg;
else
builder[1].push(arg);
const quoteMode = (/^'/.test(nextArg) || builder[0]) && !/'$/.test(nextArg);
return [quoteMode, builder[1]];
};
const args = process.argv.slice(2).reduce(unquote, [false, []])[1];
const pairs = args.filter(arg => /^--/.test(arg)).map(toPair);
const flagMap = Object.fromEntries(pairs.map(toEntry));
const onEntries = validFlags.map(flag => [toCamel(flag), toCamel(flag) in flagMap]);
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli-argv-util",
"version": "1.2.2",
"version": "1.2.3",
"description": "Simple utility to parse command line parameters and flags (arguments vector)",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -78,12 +78,12 @@
},
"devDependencies": {
"@types/node": "~20.6",
"@typescript-eslint/eslint-plugin": "~6.6",
"@typescript-eslint/parser": "~6.6",
"@typescript-eslint/eslint-plugin": "~6.7",
"@typescript-eslint/parser": "~6.7",
"add-dist-header": "~1.3",
"assert-deep-strict-equal": "~1.1",
"copy-file-util": "~1.1",
"eslint": "~8.49",
"eslint": "~8.50",
"jshint": "~2.13",
"mocha": "~10.2",
"rimraf": "~5.0",
Expand Down

0 comments on commit c45a0f4

Please sign in to comment.