cli-argv-util
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -1,2 +0,2 @@ | ||
//! cli-argv-util v1.1.0 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License | ||
//! cli-argv-util v1.2.0 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License | ||
@@ -19,3 +19,6 @@ export type StringFlagMap = { | ||
parse(validFlags: string[]): Result; | ||
run(packageJson: { | ||
[key: string]: unknown; | ||
}, posix: string): Buffer; | ||
}; | ||
export { cliArgvUtil }; |
@@ -1,6 +0,6 @@ | ||
//! cli-argv-util v1.1.0 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License | ||
//! cli-argv-util v1.2.0 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License | ||
import { execSync } from 'node:child_process'; | ||
const cliArgvUtil = { | ||
parse(validFlags) { | ||
var _a, _b; | ||
const toCamel = (token) => token.replace(/-./g, char => char[1].toUpperCase()); | ||
@@ -13,3 +13,3 @@ const toEntry = (pair) => [toCamel(pair[0]), pair[1]]; | ||
const onEntries = validFlags.map(flag => [toCamel(flag), toCamel(flag) in flagMap]); | ||
const invalidFlag = (_b = (_a = pairs.find(pair => !validFlags.includes(pair[0]))) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null; | ||
const invalidFlag = pairs.find(pair => !validFlags.includes(pair[0]))?.[0] ?? null; | ||
const helpMsg = '\nValid flags are --' + validFlags.join(' --'); | ||
@@ -26,3 +26,8 @@ const params = args.filter(arg => !/^--/.test(arg)); | ||
}, | ||
run(packageJson, posix) { | ||
const name = Object.keys(packageJson.bin).sort()[0]; | ||
const command = process.platform === 'win32' ? posix.replaceAll('\\ ', '" "') : posix; | ||
return execSync(command.replace(name, 'node bin/cli.js'), { stdio: 'inherit' }); | ||
}, | ||
}; | ||
export { cliArgvUtil }; |
{ | ||
"name": "cli-argv-util", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Simple utility to parse command line parameters and flags (arguments vector)", | ||
@@ -75,15 +75,15 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "~20.3", | ||
"@typescript-eslint/eslint-plugin": "~5.60", | ||
"@typescript-eslint/parser": "~5.60", | ||
"add-dist-header": "~1.0", | ||
"assert-deep-strict-equal": "~1.0", | ||
"@types/node": "~20.4", | ||
"@typescript-eslint/eslint-plugin": "~6.0", | ||
"@typescript-eslint/parser": "~6.0", | ||
"add-dist-header": "~1.1", | ||
"assert-deep-strict-equal": "~1.1", | ||
"copy-file-util": "~1.1", | ||
"eslint": "~8.43", | ||
"eslint": "~8.44", | ||
"jshint": "~2.13", | ||
"mocha": "~10.2", | ||
"rimraf": "~5.0", | ||
"run-scripts-util": "~1.1", | ||
"run-scripts-util": "~1.2", | ||
"typescript": "~5.1" | ||
} | ||
} |
@@ -8,3 +8,2 @@ # cli-argv-util | ||
[![npm](https://img.shields.io/npm/v/cli-argv-util.svg)](https://www.npmjs.com/package/cli-argv-util) | ||
[![Vulnerabilities](https://snyk.io/test/github/center-key/cli-argv-util/badge.svg)](https://snyk.io/test/github/center-key/cli-argv-util) | ||
[![Build](https://github.com/center-key/cli-argv-util/workflows/build/badge.svg)](https://github.com/center-key/cli-argv-util/actions/workflows/run-spec-on-push.yaml) | ||
@@ -11,0 +10,0 @@ |
9181
52
85