New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

argufy

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argufy - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

24

build/index.js
/**
* @param {string[]} argv
* @param {*} long
* @param {*} short
* @param {*} bool
* @param {*} number
* @param {Array<string>} argv
* @param {string} long
* @param {string} short
* @param {boolean} bool
* @param {boolean} number
*/
const find = (argv, long, short, bool, number) => {
const find = (argv, long, short, bool = false, number = false) => {
const re = new RegExp(`^-(${short}|-${long})`)

@@ -71,4 +71,4 @@ const i = argv.findIndex(a => re.test(a))

*
* @param {string[]} [args] Array with arguments to parse. `process.argv` is used by default. It is assumed that user arguments start from the 3rd position.
* @returns {Object.<string, string|string[]|boolean|number>} An object with all found values for the configuration request.
* @param {Array<string>} [args] Array with arguments to parse. `process.argv` is used by default. It is assumed that user arguments start from the 3rd position.
* @returns {Object.<string, string|Array<string>|boolean|number>} An object with all found values for the configuration request.
*/

@@ -80,4 +80,5 @@ function argufy(config = {}, args = process.argv) {

argv = argv.slice(titles.length)
let commandFound = !titles.length
const res = Object.keys(config).reduce(({ _argv, ...acc }, key) => {
if (_argv.length == 0) return { _argv, ...acc }
if (_argv.length == 0 && commandFound) return { _argv, ...acc }
const val = config[key]

@@ -92,4 +93,6 @@ let value

value = titles
commandFound = true
} else if (command && titles.length) {
value = titles[0]
commandFound = true
} else {

@@ -132,6 +135,5 @@ ({ value, argv: _argv } = find(_argv, key, short, boolean, number))

/**
* @typedef {Object.<string, string|Flag>} Config
* @typedef {Object.<string, (string|Flag)>} Config
*/
module.exports = argufy
## 14 January 2019
### 1.3.2
- [fix] Read the command without other flags.
- [doc] Better types for Closure.
### 1.3.1

@@ -4,0 +9,0 @@

{
"name": "argufy",
"version": "1.3.1",
"version": "1.3.2",
"description": "Parse command line arguments to Node.js CLI programs.",

@@ -5,0 +5,0 @@ "main": "build",

/**
* @param {string[]} argv
* @param {*} long
* @param {*} short
* @param {*} bool
* @param {*} number
* @param {Array<string>} argv
* @param {string} long
* @param {string} short
* @param {boolean} bool
* @param {boolean} number
*/
const find = (argv, long, short, bool, number) => {
const find = (argv, long, short, bool = false, number = false) => {
const re = new RegExp(`^-(${short}|-${long})`)

@@ -71,4 +71,4 @@ const i = argv.findIndex(a => re.test(a))

*
* @param {string[]} [args] Array with arguments to parse. `process.argv` is used by default. It is assumed that user arguments start from the 3rd position.
* @returns {Object.<string, string|string[]|boolean|number>} An object with all found values for the configuration request.
* @param {Array<string>} [args] Array with arguments to parse. `process.argv` is used by default. It is assumed that user arguments start from the 3rd position.
* @returns {Object.<string, string|Array<string>|boolean|number>} An object with all found values for the configuration request.
*/

@@ -80,4 +80,5 @@ export default function argufy(config = {}, args = process.argv) {

argv = argv.slice(titles.length)
let commandFound = !titles.length
const res = Object.keys(config).reduce(({ _argv, ...acc }, key) => {
if (_argv.length == 0) return { _argv, ...acc }
if (_argv.length == 0 && commandFound) return { _argv, ...acc }
const val = config[key]

@@ -92,4 +93,6 @@ let value

value = titles
commandFound = true
} else if (command && titles.length) {
value = titles[0]
commandFound = true
} else {

@@ -132,3 +135,3 @@ ({ value, argv: _argv } = find(_argv, key, short, boolean, number))

/**
* @typedef {Object.<string, string|Flag>} Config
*/
* @typedef {Object.<string, (string|Flag)>} Config
*/
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc