cli-argument-parser
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -0,0 +0,0 @@ /** |
@@ -24,7 +24,7 @@ "use strict"; | ||
const finalArgumentsList = {}; | ||
const argumentsList = process.argv.filter((argument) => argument.startsWith(prefix) && argument.indexOf(seperator) !== -1); | ||
const argumentsList = filterer(prefix, seperator); | ||
for (const argument of argumentsList) { | ||
const splitArgument = argument.split(seperator); | ||
const splitArgument = (seperator !== '') ? argument.split(seperator) : [argument, undefined]; | ||
const name = splitArgument[0].replace(prefix, ''); | ||
const value = splitArgument[1]; | ||
const value = (splitArgument[1] !== undefined) ? splitArgument[1] : ''; | ||
finalArgumentsList[name] = value; | ||
@@ -35,1 +35,13 @@ } | ||
exports.filterArguments = filterArguments; | ||
/** | ||
* A filter function to filter by dynamic prefix & seperator | ||
* @param prefix The prefix of the argument | ||
* @param seperator The seperator of the argument | ||
*/ | ||
function filterer(prefix, seperator) { | ||
if (prefix !== '' && seperator === '') | ||
return process.argv.filter((argument) => argument.startsWith(prefix)); | ||
else if (prefix === '' && seperator !== '') | ||
return process.argv.filter((argument) => argument.indexOf(seperator) !== -1); | ||
return process.argv; | ||
} |
{ | ||
"name": "cli-argument-parser", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A package containing relevant CLI actions", | ||
@@ -13,3 +13,3 @@ "main": "lib/index.js", | ||
"pre-deploy": "npm run unit-tests && npm run configuration-unit-tests && npm run build", | ||
"deploy": "npm version patch && npm publish" | ||
"deploy": "npm-deploy cli-argument-parser" | ||
}, | ||
@@ -31,7 +31,8 @@ "repository": { | ||
"@types/chai": "^4.2.11", | ||
"@types/file-exists": "4.0.0", | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "14.0.5", | ||
"chai": "^4.2.0", | ||
"mocha": "^8.0.1", | ||
"chai": "^4.2.0", | ||
"@types/file-exists": "4.0.0", | ||
"@types/node": "14.0.5", | ||
"npm-package-deployer": "0.0.6", | ||
"ts-jest": "^26.0.0", | ||
@@ -38,0 +39,0 @@ "ts-node": "^8.10.2", |
@@ -0,0 +0,0 @@ # Command-line Argument Parser · [![GitHub license](https://img.shields.io/badge/license-BSD%203%20Clause-blue.svg)](https://github.com/danitseitlin/cli-argument-parser/blob/master/LICENSE) [![npm version](http://img.shields.io/npm/v/cli-argument-parser.svg?style=flat)](https://npmjs.org/package/cli-argument-parser "View this project on npm") ![CI](https://github.com/danitseitlin/cli-argument-parser/workflows/CI/badge.svg) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6507
59
10