cli-argv-util
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -1,2 +0,2 @@ | ||
//! cli-argv-util v1.2.3 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License | ||
//! cli-argv-util v1.2.4 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License | ||
@@ -23,3 +23,4 @@ export type StringFlagMap = { | ||
readFolder(folder: string): string[]; | ||
unquoteArgs(args: string[]): string[]; | ||
}; | ||
export { cliArgvUtil }; |
@@ -1,2 +0,2 @@ | ||
//! cli-argv-util v1.2.3 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License | ||
//! cli-argv-util v1.2.4 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License | ||
@@ -11,13 +11,3 @@ import { execSync } from 'node:child_process'; | ||
const toPair = (flag) => flag.replace(/^--/, '').split('='); | ||
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 args = cliArgvUtil.unquoteArgs(process.argv.slice(2)); | ||
const pairs = args.filter(arg => /^--/.test(arg)).map(toPair); | ||
@@ -46,3 +36,16 @@ const flagMap = Object.fromEntries(pairs.map(toEntry)); | ||
}, | ||
unquoteArgs(args) { | ||
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]]; | ||
}; | ||
return args.reduce(unquote, [false, []])[1]; | ||
}, | ||
}; | ||
export { cliArgvUtil }; |
{ | ||
"name": "cli-argv-util", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Simple utility to parse command line parameters and flags (arguments vector)", | ||
@@ -19,3 +19,6 @@ "license": "MIT", | ||
}, | ||
"repository": "github:center-key/cli-argv-util", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/center-key/cli-argv-util.git" | ||
}, | ||
"homepage": "https://github.com/center-key/cli-argv-util", | ||
@@ -22,0 +25,0 @@ "bugs": "https://github.com/center-key/cli-argv-util/issues", |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
10308
72
1