shell-quote
Advanced tools
Comparing version 1.6.1 to 1.6.2
19
index.js
@@ -1,8 +0,3 @@ | ||
var json = typeof JSON !== undefined ? JSON : require('jsonify'); | ||
var map = require('array-map'); | ||
var filter = require('array-filter'); | ||
var reduce = require('array-reduce'); | ||
exports.quote = function (xs) { | ||
return map(xs, function (s) { | ||
return xs.map(function (s) { | ||
if (s && typeof s === 'object') { | ||
@@ -39,9 +34,9 @@ return s.op.replace(/(.)/g, '\\$1'); | ||
if (typeof env !== 'function') return mapped; | ||
return reduce(mapped, function (acc, s) { | ||
return mapped.reduce(function (acc, s) { | ||
if (typeof s === 'object') return acc.concat(s); | ||
var xs = s.split(RegExp('(' + TOKEN + '.*?' + TOKEN + ')', 'g')); | ||
if (xs.length === 1) return acc.concat(xs[0]); | ||
return acc.concat(map(filter(xs, Boolean), function (x) { | ||
return acc.concat(xs.filter(Boolean).map(function (x) { | ||
if (RegExp('^' + TOKEN).test(x)) { | ||
return json.parse(x.split(TOKEN)[1]); | ||
return JSON.parse(x.split(TOKEN)[1]); | ||
} | ||
@@ -58,3 +53,3 @@ else return x; | ||
].join('|'), 'g'); | ||
var match = filter(s.match(chunker), Boolean); | ||
var match = s.match(chunker).filter(Boolean); | ||
var commented = false; | ||
@@ -65,3 +60,3 @@ | ||
if (!opts) opts = {}; | ||
return map(match, function (s, j) { | ||
return match.map(function (s, j) { | ||
if (commented) { | ||
@@ -198,3 +193,3 @@ return; | ||
if (typeof r === 'object') { | ||
return pre + TOKEN + json.stringify(r) + TOKEN; | ||
return pre + TOKEN + JSON.stringify(r) + TOKEN; | ||
} | ||
@@ -201,0 +196,0 @@ else return pre + r; |
{ | ||
"name": "shell-quote", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "quote and parse shell commands", | ||
@@ -45,8 +45,3 @@ "main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"jsonify": "~0.0.0", | ||
"array-filter": "~0.0.0", | ||
"array-reduce": "~0.0.0", | ||
"array-map": "~0.0.0" | ||
} | ||
"dependencies": {} | ||
} |
@@ -14,12 +14,12 @@ var test = require('tape'); | ||
); | ||
t.equal(quote([]), ''); | ||
t.equal(quote(["a\nb"]), "'a\nb'"); | ||
t.equal(quote([' #(){}*|][!']), "' #(){}*|][!'"); | ||
t.equal(quote(["'#(){}*|][!"]), '"\'#(){}*|][\\!"'); | ||
t.equal(quote(["X#(){}*|][!"]), "X\\#\\(\\)\\{\\}\\*\\|\\]\\[\\!"); | ||
t.equal(quote(["a\n#\nb"]), "'a\n#\nb'"); | ||
t.equal(quote(['><;{}']), '\\>\\<\\;\\{\\}'); | ||
t.equal(quote([ 'a', 1, true, false ]), 'a 1 true false'); | ||
t.equal(quote([ 'a', 1, null, undefined ]), 'a 1 null undefined'); | ||
t.end(); | ||
t.equal(quote([]), ''); | ||
t.equal(quote(["a\nb"]), "'a\nb'"); | ||
t.equal(quote([' #(){}*|][!']), "' #(){}*|][!'"); | ||
t.equal(quote(["'#(){}*|][!"]), '"\'#(){}*|][\\!"'); | ||
t.equal(quote(["X#(){}*|][!"]), "X\\#\\(\\)\\{\\}\\*\\|\\]\\[\\!"); | ||
t.equal(quote(["a\n#\nb"]), "'a\n#\nb'"); | ||
t.equal(quote(['><;{}']), '\\>\\<\\;\\{\\}'); | ||
t.equal(quote([ 'a', 1, true, false ]), 'a 1 true false'); | ||
t.equal(quote([ 'a', 1, null, undefined ]), 'a 1 null undefined'); | ||
t.end(); | ||
}); | ||
@@ -26,0 +26,0 @@ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
0
17
19440
391
1
- Removedarray-filter@~0.0.0
- Removedarray-map@~0.0.0
- Removedarray-reduce@~0.0.0
- Removedjsonify@~0.0.0
- Removedarray-filter@0.0.1(transitive)
- Removedarray-map@0.0.1(transitive)
- Removedarray-reduce@0.0.0(transitive)
- Removedjsonify@0.0.1(transitive)