Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expand-args

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expand-args - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

readme.md

68

index.js

@@ -10,3 +10,3 @@ /*!

var expand = require('expand-object');
var utils = require('./utils');

@@ -22,7 +22,46 @@ function expandArgs(argv) {

var orig = argv[key];
if (typeof orig === 'string') {
orig = orig.split('/').join('__SLASH__');
}
if (utils.typeOf(orig) === 'object') {
res[key] = expandArgs(orig);
continue;
}
var val = orig.toString();
if ((/[\\\/]/.test(val) || /\/\./.test(val))) {
if (/:/.test(val)) {
res[key] = emit(val).split('|').reduce(function (acc, ele) {
var o = {};
var segs = ele.split(':');
var v = segs[1].split('\\.').join('.');
if (/,/.test(v)) {
v = v.split(',');
}
utils.set(o, segs[0], v);
extend(acc, o);
return acc;
}, {});
continue;
}
if (/,/.test(val)) {
res[key] = emit(val).split('|').reduce(function (acc, ele) {
var arr = ele.split('\\.').join('.').split(',');
return acc.concat(arr);
}, []);
continue;
}
if (val.indexOf('./') === 0) {
res[key] = emit(val);
continue;
}
}
if (~key.indexOf(':') && val === 'true') {
var parts = key.split(':');
res[parts[0]] = parts[1];
res[parts[0]] = emit(parts[1]);
continue;

@@ -40,6 +79,6 @@ }

if (/\W/.test(ele)) {
extend(res, expand(ele));
extend(res, utils.expand(ele));
} else {
res._ = res._ || [];
res._.push(ele);
res._.push(emit(ele));
}

@@ -57,7 +96,7 @@ }

if (typeof orig === 'string' && /\W/.test(orig)) {
res[key] = expand(orig, {toBoolean: true});
res[key] = utils.expand(emit(orig), {toBoolean: true});
continue;
}
res[key] = orig;
res[key] = emit(orig);
}

@@ -68,13 +107,24 @@ return res;

function extend(a, b) {
for (var key in b) a[key] = b[key];
for (var key in b) {
a[key] = b[key];
}
return a;
};
}
function expandEach(arr) {
return arr.map(function (ele) {
ele = emit(ele);
if (!/\W/.test(ele)) return ele;
return expand(ele, {toBoolean: true});
return utils.expand(ele, {
toBoolean: true
});
});
}
function emit(str) {
str = str.split('__SLASH__').join('/');
return str;
}
/**

@@ -81,0 +131,0 @@ * Expose an instance of `expandArgs` plugin

22

package.json
{
"name": "expand-args",
"description": "Expand parsed command line arguments using expand-object.",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/jonschlinkert/expand-args",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/expand-args",
"bugs": {
"url": "https://github.com/jonschlinkert/expand-args/issues"
},
"bugs": "https://github.com/jonschlinkert/expand-args/issues",
"license": "MIT",
"files": [
"index.js"
"index.js",
"utils.js"
],

@@ -23,3 +22,7 @@ "main": "index.js",

"dependencies": {
"expand-object": "^0.3.8"
"expand-object": "^0.3.8",
"extend-shallow": "^2.0.1",
"kind-of": "^2.0.1",
"lazy-cache": "^0.2.4",
"set-value": "^0.3.0"
},

@@ -42,3 +45,8 @@ "devDependencies": {

"object"
]
],
"verb": {
"related": {
"list": ["expand-object"]
}
}
}
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