Comparing version 1.3.0 to 1.4.0
@@ -9,3 +9,2 @@ 'use strict'; | ||
var path = _interopDefault(require('path')); | ||
var shellQuote = _interopDefault(require('shell-quote')); | ||
@@ -590,2 +589,704 @@ // node_modules/es-tostring/index.mjs | ||
// node_modules/jsonify/lib/parse.js | ||
var at; | ||
var ch; | ||
var escapee = { | ||
'"': '"', | ||
'\\': '\\', | ||
'/': '/', | ||
b: '\b', | ||
f: '\f', | ||
n: '\n', | ||
r: '\r', | ||
t: '\t' | ||
}; | ||
var text; | ||
var error$1 = function (m) { | ||
// Call error when something is wrong. | ||
throw { | ||
name: 'SyntaxError', | ||
message: m, | ||
at: at, | ||
text: text | ||
}; | ||
}; | ||
var next = function (c) { | ||
// If a c parameter is provided, verify that it matches the current character. | ||
if (c && c !== ch) { | ||
error$1("Expected '" + c + "' instead of '" + ch + "'"); | ||
} | ||
// Get the next character. When there are no more characters, | ||
// return the empty string. | ||
ch = text.charAt(at); | ||
at += 1; | ||
return ch; | ||
}; | ||
var number = function () { | ||
// Parse a number value. | ||
var number, | ||
string = ''; | ||
if (ch === '-') { | ||
string = '-'; | ||
next('-'); | ||
} | ||
while (ch >= '0' && ch <= '9') { | ||
string += ch; | ||
next(); | ||
} | ||
if (ch === '.') { | ||
string += '.'; | ||
while (next() && ch >= '0' && ch <= '9') { | ||
string += ch; | ||
} | ||
} | ||
if (ch === 'e' || ch === 'E') { | ||
string += ch; | ||
next(); | ||
if (ch === '-' || ch === '+') { | ||
string += ch; | ||
next(); | ||
} | ||
while (ch >= '0' && ch <= '9') { | ||
string += ch; | ||
next(); | ||
} | ||
} | ||
number = +string; | ||
if (!isFinite(number)) { | ||
error$1("Bad number"); | ||
} else { | ||
return number; | ||
} | ||
}; | ||
var string$2 = function () { | ||
// Parse a string value. | ||
var hex, | ||
i, | ||
string = '', | ||
uffff; | ||
// When parsing for string values, we must look for " and \ characters. | ||
if (ch === '"') { | ||
while (next()) { | ||
if (ch === '"') { | ||
next(); | ||
return string; | ||
} else if (ch === '\\') { | ||
next(); | ||
if (ch === 'u') { | ||
uffff = 0; | ||
for (i = 0; i < 4; i += 1) { | ||
hex = parseInt(next(), 16); | ||
if (!isFinite(hex)) { | ||
break; | ||
} | ||
uffff = uffff * 16 + hex; | ||
} | ||
string += String.fromCharCode(uffff); | ||
} else if (typeof escapee[ch] === 'string') { | ||
string += escapee[ch]; | ||
} else { | ||
break; | ||
} | ||
} else { | ||
string += ch; | ||
} | ||
} | ||
} | ||
error$1("Bad string"); | ||
}; | ||
var white = function () { | ||
// Skip whitespace. | ||
while (ch && ch <= ' ') { | ||
next(); | ||
} | ||
}; | ||
var word = function () { | ||
// true, false, or null. | ||
switch (ch) { | ||
case 't': | ||
next('t'); | ||
next('r'); | ||
next('u'); | ||
next('e'); | ||
return true; | ||
case 'f': | ||
next('f'); | ||
next('a'); | ||
next('l'); | ||
next('s'); | ||
next('e'); | ||
return false; | ||
case 'n': | ||
next('n'); | ||
next('u'); | ||
next('l'); | ||
next('l'); | ||
return null; | ||
} | ||
error$1("Unexpected '" + ch + "'"); | ||
}; | ||
var value; | ||
var array$1 = function () { | ||
// Parse an array value. | ||
var array = []; | ||
if (ch === '[') { | ||
next('['); | ||
white(); | ||
if (ch === ']') { | ||
next(']'); | ||
return array; // empty array | ||
} | ||
while (ch) { | ||
array.push(value()); | ||
white(); | ||
if (ch === ']') { | ||
next(']'); | ||
return array; | ||
} | ||
next(','); | ||
white(); | ||
} | ||
} | ||
error$1("Bad array"); | ||
}; | ||
var object$2 = function () { | ||
// Parse an object value. | ||
var key, | ||
object = {}; | ||
if (ch === '{') { | ||
next('{'); | ||
white(); | ||
if (ch === '}') { | ||
next('}'); | ||
return object; // empty object | ||
} | ||
while (ch) { | ||
key = string$2(); | ||
white(); | ||
next(':'); | ||
if (Object.hasOwnProperty.call(object, key)) { | ||
error$1('Duplicate key "' + key + '"'); | ||
} | ||
object[key] = value(); | ||
white(); | ||
if (ch === '}') { | ||
next('}'); | ||
return object; | ||
} | ||
next(','); | ||
white(); | ||
} | ||
} | ||
error$1("Bad object"); | ||
}; | ||
value = function () { | ||
// Parse a JSON value. It could be an object, an array, a string, a number, | ||
// or a word. | ||
white(); | ||
switch (ch) { | ||
case '{': | ||
return object$2(); | ||
case '[': | ||
return array$1(); | ||
case '"': | ||
return string$2(); | ||
case '-': | ||
return number(); | ||
default: | ||
return ch >= '0' && ch <= '9' ? number() : word(); | ||
} | ||
}; | ||
// Return the json_parse function. It will have access to all of the above | ||
// functions and variables. | ||
var parse$3 = function (source, reviver) { | ||
var result; | ||
text = source; | ||
at = 0; | ||
ch = ' '; | ||
result = value(); | ||
white(); | ||
if (ch) { | ||
error$1("Syntax error"); | ||
} | ||
// If there is a reviver function, we recursively walk the new structure, | ||
// passing each name/value pair to the reviver function for possible | ||
// transformation, starting with a temporary root object that holds the result | ||
// in an empty key. If there is not a reviver function, we simply return the | ||
// result. | ||
return typeof reviver === 'function' ? (function walk(holder, key) { | ||
var k, v, value = holder[key]; | ||
if (value && typeof value === 'object') { | ||
for (k in value) { | ||
if (Object.prototype.hasOwnProperty.call(value, k)) { | ||
v = walk(value, k); | ||
if (v !== undefined) { | ||
value[k] = v; | ||
} else { | ||
delete value[k]; | ||
} | ||
} | ||
} | ||
} | ||
return reviver.call(holder, key, value); | ||
}({'': result}, '')) : result; | ||
}; | ||
// node_modules/jsonify/lib/stringify.js | ||
var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
var gap; | ||
var indent; | ||
var meta = { // table of character substitutions | ||
'\b': '\\b', | ||
'\t': '\\t', | ||
'\n': '\\n', | ||
'\f': '\\f', | ||
'\r': '\\r', | ||
'"' : '\\"', | ||
'\\': '\\\\' | ||
}; | ||
var rep; | ||
function quote$1(string) { | ||
// If the string contains no control characters, no quote characters, and no | ||
// backslash characters, then we can safely slap some quotes around it. | ||
// Otherwise we must also replace the offending characters with safe escape | ||
// sequences. | ||
escapable.lastIndex = 0; | ||
return escapable.test(string) ? '"' + string.replace(escapable, function (a) { | ||
var c = meta[a]; | ||
return typeof c === 'string' ? c : | ||
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); | ||
}) + '"' : '"' + string + '"'; | ||
} | ||
function str(key, holder) { | ||
// Produce a string from holder[key]. | ||
var i, // The loop counter. | ||
k, // The member key. | ||
v, // The member value. | ||
length, | ||
mind = gap, | ||
partial, | ||
value = holder[key]; | ||
// If the value has a toJSON method, call it to obtain a replacement value. | ||
if (value && typeof value === 'object' && | ||
typeof value.toJSON === 'function') { | ||
value = value.toJSON(key); | ||
} | ||
// If we were called with a replacer function, then call the replacer to | ||
// obtain a replacement value. | ||
if (typeof rep === 'function') { | ||
value = rep.call(holder, key, value); | ||
} | ||
// What happens next depends on the value's type. | ||
switch (typeof value) { | ||
case 'string': | ||
return quote$1(value); | ||
case 'number': | ||
// JSON numbers must be finite. Encode non-finite numbers as null. | ||
return isFinite(value) ? String(value) : 'null'; | ||
case 'boolean': | ||
case 'null': | ||
// If the value is a boolean or null, convert it to a string. Note: | ||
// typeof null does not produce 'null'. The case is included here in | ||
// the remote chance that this gets fixed someday. | ||
return String(value); | ||
case 'object': | ||
if (!value) return 'null'; | ||
gap += indent; | ||
partial = []; | ||
// Array.isArray | ||
if (Object.prototype.toString.apply(value) === '[object Array]') { | ||
length = value.length; | ||
for (i = 0; i < length; i += 1) { | ||
partial[i] = str(i, value) || 'null'; | ||
} | ||
// Join all of the elements together, separated with commas, and | ||
// wrap them in brackets. | ||
v = partial.length === 0 ? '[]' : gap ? | ||
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : | ||
'[' + partial.join(',') + ']'; | ||
gap = mind; | ||
return v; | ||
} | ||
// If the replacer is an array, use it to select the members to be | ||
// stringified. | ||
if (rep && typeof rep === 'object') { | ||
length = rep.length; | ||
for (i = 0; i < length; i += 1) { | ||
k = rep[i]; | ||
if (typeof k === 'string') { | ||
v = str(k, value); | ||
if (v) { | ||
partial.push(quote$1(k) + (gap ? ': ' : ':') + v); | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
// Otherwise, iterate through all of the keys in the object. | ||
for (k in value) { | ||
if (Object.prototype.hasOwnProperty.call(value, k)) { | ||
v = str(k, value); | ||
if (v) { | ||
partial.push(quote$1(k) + (gap ? ': ' : ':') + v); | ||
} | ||
} | ||
} | ||
} | ||
// Join all of the member texts together, separated with commas, | ||
// and wrap them in braces. | ||
v = partial.length === 0 ? '{}' : gap ? | ||
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : | ||
'{' + partial.join(',') + '}'; | ||
gap = mind; | ||
return v; | ||
} | ||
} | ||
var stringify$1 = function (value, replacer, space) { | ||
var i; | ||
gap = ''; | ||
indent = ''; | ||
// If the space parameter is a number, make an indent string containing that | ||
// many spaces. | ||
if (typeof space === 'number') { | ||
for (i = 0; i < space; i += 1) { | ||
indent += ' '; | ||
} | ||
} | ||
// If the space parameter is a string, it will be used as the indent string. | ||
else if (typeof space === 'string') { | ||
indent = space; | ||
} | ||
// If there is a replacer, it must be a function or an array. | ||
// Otherwise, throw an error. | ||
rep = replacer; | ||
if (replacer && typeof replacer !== 'function' | ||
&& (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { | ||
throw new Error('JSON.stringify'); | ||
} | ||
// Make a fake root object containing our value under the key of ''. | ||
// Return the result of stringifying the value. | ||
return str('', {'': value}); | ||
}; | ||
// commonjs-proxy:/Users/zk/play/executive/node_modules/jsonify/lib/parse.js | ||
// commonjs-proxy:/Users/zk/play/executive/node_modules/jsonify/lib/stringify.js | ||
// node_modules/jsonify/index.js | ||
var parse$2 = parse$3; | ||
var stringify = stringify$1; | ||
var index$1 = { | ||
parse: parse$2, | ||
stringify: stringify | ||
}; | ||
// node_modules/array-map/index.js | ||
var index$3 = function (xs, f) { | ||
if (xs.map) return xs.map(f); | ||
var res = []; | ||
for (var i = 0; i < xs.length; i++) { | ||
var x = xs[i]; | ||
if (hasOwn$1.call(xs, i)) res.push(f(x, i, xs)); | ||
} | ||
return res; | ||
}; | ||
var hasOwn$1 = Object.prototype.hasOwnProperty; | ||
// node_modules/array-filter/index.js | ||
/** | ||
* Array#filter. | ||
* | ||
* @param {Array} arr | ||
* @param {Function} fn | ||
* @return {Array} | ||
*/ | ||
var index$5 = function (arr, fn) { | ||
if (arr.filter) return arr.filter(fn); | ||
var ret = []; | ||
for (var i = 0; i < arr.length; i++) { | ||
if (!hasOwn$2.call(arr, i)) continue; | ||
if (fn(arr[i], i, arr)) ret.push(arr[i]); | ||
} | ||
return ret; | ||
}; | ||
var hasOwn$2 = Object.prototype.hasOwnProperty; | ||
// node_modules/array-reduce/index.js | ||
var hasOwn$3 = Object.prototype.hasOwnProperty; | ||
var index$7 = function (xs, f, acc) { | ||
var hasAcc = arguments.length >= 3; | ||
if (hasAcc && xs.reduce) return xs.reduce(f, acc); | ||
if (xs.reduce) return xs.reduce(f); | ||
for (var i = 0; i < xs.length; i++) { | ||
if (!hasOwn$3.call(xs, i)) continue; | ||
if (!hasAcc) { | ||
acc = xs[i]; | ||
hasAcc = true; | ||
continue; | ||
} | ||
acc = f(acc, xs[i], i); | ||
} | ||
return acc; | ||
}; | ||
// commonjs-proxy:/Users/zk/play/executive/node_modules/jsonify/index.js | ||
// commonjs-proxy:/Users/zk/play/executive/node_modules/array-map/index.js | ||
// commonjs-proxy:/Users/zk/play/executive/node_modules/array-filter/index.js | ||
// commonjs-proxy:/Users/zk/play/executive/node_modules/array-reduce/index.js | ||
// node_modules/shell-quote/index.js | ||
var json = typeof JSON !== undefined ? JSON : index$1; | ||
var quote = function (xs) { | ||
return index$3(xs, function (s) { | ||
if (s && typeof s === 'object') { | ||
return s.op.replace(/(.)/g, '\\$1'); | ||
} | ||
else if (/["\s]/.test(s) && !/'/.test(s)) { | ||
return "'" + s.replace(/(['\\])/g, '\\$1') + "'"; | ||
} | ||
else if (/["'\s]/.test(s)) { | ||
return '"' + s.replace(/(["\\$`!])/g, '\\$1') + '"'; | ||
} | ||
else { | ||
return String(s).replace(/([#!"$&'()*,:;<=>?@\[\\\]^`{|}])/g, '\\$1'); | ||
} | ||
}).join(' '); | ||
}; | ||
var CONTROL = '(?:' + [ | ||
'\\|\\|', '\\&\\&', ';;', '\\|\\&', '[&;()|<>]' | ||
].join('|') + ')'; | ||
var META = '|&;()<> \\t'; | ||
var BAREWORD = '(\\\\[\'"' + META + ']|[^\\s\'"' + META + '])+'; | ||
var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"'; | ||
var DOUBLE_QUOTE = '\'((\\\\\'|[^\'])*?)\''; | ||
var TOKEN = ''; | ||
for (var i = 0; i < 4; i++) { | ||
TOKEN += (Math.pow(16,8)*Math.random()).toString(16); | ||
} | ||
var parse_1 = function (s, env, opts) { | ||
var mapped = parse$1(s, env, opts); | ||
if (typeof env !== 'function') return mapped; | ||
return index$7(mapped, 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(index$3(index$5(xs, Boolean), function (x) { | ||
if (RegExp('^' + TOKEN).test(x)) { | ||
return json.parse(x.split(TOKEN)[1]); | ||
} | ||
else return x; | ||
})); | ||
}, []); | ||
}; | ||
function parse$1 (s, env, opts) { | ||
var chunker = new RegExp([ | ||
'(' + CONTROL + ')', // control chars | ||
'(' + BAREWORD + '|' + SINGLE_QUOTE + '|' + DOUBLE_QUOTE + ')*' | ||
].join('|'), 'g'); | ||
var match = index$5(s.match(chunker), Boolean); | ||
var commented = false; | ||
if (!match) return []; | ||
if (!env) env = {}; | ||
if (!opts) opts = {}; | ||
return index$3(match, function (s, j) { | ||
if (commented) { | ||
return; | ||
} | ||
if (RegExp('^' + CONTROL + '$').test(s)) { | ||
return { op: s }; | ||
} | ||
// Hand-written scanner/parser for Bash quoting rules: | ||
// | ||
// 1. inside single quotes, all characters are printed literally. | ||
// 2. inside double quotes, all characters are printed literally | ||
// except variables prefixed by '$' and backslashes followed by | ||
// either a double quote or another backslash. | ||
// 3. outside of any quotes, backslashes are treated as escape | ||
// characters and not printed (unless they are themselves escaped) | ||
// 4. quote context can switch mid-token if there is no whitespace | ||
// between the two quote contexts (e.g. all'one'"token" parses as | ||
// "allonetoken") | ||
var SQ = "'"; | ||
var DQ = '"'; | ||
var DS = '$'; | ||
var BS = opts.escape || '\\'; | ||
var quote = false; | ||
var esc = false; | ||
var out = ''; | ||
var isGlob = false; | ||
for (var i = 0, len = s.length; i < len; i++) { | ||
var c = s.charAt(i); | ||
isGlob = isGlob || (!quote && (c === '*' || c === '?')); | ||
if (esc) { | ||
out += c; | ||
esc = false; | ||
} | ||
else if (quote) { | ||
if (c === quote) { | ||
quote = false; | ||
} | ||
else if (quote == SQ) { | ||
out += c; | ||
} | ||
else { // Double quote | ||
if (c === BS) { | ||
i += 1; | ||
c = s.charAt(i); | ||
if (c === DQ || c === BS || c === DS) { | ||
out += c; | ||
} else { | ||
out += BS + c; | ||
} | ||
} | ||
else if (c === DS) { | ||
out += parseEnvVar(); | ||
} | ||
else { | ||
out += c; | ||
} | ||
} | ||
} | ||
else if (c === DQ || c === SQ) { | ||
quote = c; | ||
} | ||
else if (RegExp('^' + CONTROL + '$').test(c)) { | ||
return { op: s }; | ||
} | ||
else if (RegExp('^#$').test(c)) { | ||
commented = true; | ||
if (out.length){ | ||
return [out, { comment: s.slice(i+1) + match.slice(j+1).join(' ') }]; | ||
} | ||
return [{ comment: s.slice(i+1) + match.slice(j+1).join(' ') }]; | ||
} | ||
else if (c === BS) { | ||
esc = true; | ||
} | ||
else if (c === DS) { | ||
out += parseEnvVar(); | ||
} | ||
else out += c; | ||
} | ||
if (isGlob) return {op: 'glob', pattern: out}; | ||
return out; | ||
function parseEnvVar() { | ||
i += 1; | ||
var varend, varname; | ||
//debugger | ||
if (s.charAt(i) === '{') { | ||
i += 1; | ||
if (s.charAt(i) === '}') { | ||
throw new Error("Bad substitution: " + s.substr(i - 2, 3)); | ||
} | ||
varend = s.indexOf('}', i); | ||
if (varend < 0) { | ||
throw new Error("Bad substitution: " + s.substr(i)); | ||
} | ||
varname = s.substr(i, varend - i); | ||
i = varend; | ||
} | ||
else if (/[*@#?$!_\-]/.test(s.charAt(i))) { | ||
varname = s.charAt(i); | ||
i += 1; | ||
} | ||
else { | ||
varend = s.substr(i).match(/[^\w\d_]/); | ||
if (!varend) { | ||
varname = s.substr(i); | ||
i = s.length; | ||
} else { | ||
varname = s.substr(i, varend.index); | ||
i += varend.index - 1; | ||
} | ||
} | ||
return getVar(null, '', varname); | ||
} | ||
}) | ||
// finalize parsed aruments | ||
.reduce(function(prev, arg){ | ||
if (arg === undefined){ | ||
return prev; | ||
} | ||
return prev.concat(arg); | ||
},[]); | ||
function getVar (_, pre, key) { | ||
var r = typeof env === 'function' ? env(key) : env[key]; | ||
if (r === undefined) r = ''; | ||
if (typeof r === 'object') { | ||
return pre + TOKEN + json.stringify(r) + TOKEN; | ||
} | ||
else return pre + r; | ||
} | ||
} | ||
var index = { | ||
quote: quote, | ||
parse: parse_1 | ||
}; | ||
// src/spawn/parse.coffee | ||
@@ -625,3 +1326,3 @@ var isWin; | ||
var args, cmd, env, k, ref, ref1, v; | ||
args = shellQuote.parse(s); | ||
args = index.parse(s); | ||
env = {}; | ||
@@ -651,3 +1352,3 @@ while (cmd = args.shift()) { | ||
var parse = function(cmd, opts) { | ||
var parse$$1 = function(cmd, opts) { | ||
var args, env, ref, ref1, ref2; | ||
@@ -714,3 +1415,3 @@ if (opts == null) { | ||
var args, child, done, exit, ref, ref1, ref2, ref3, stderr, stdout; | ||
ref = parse(cmd, opts), cmd = ref[0], args = ref[1], opts = ref[2]; | ||
ref = parse$$1(cmd, opts), cmd = ref[0], args = ref[1], opts = ref[2]; | ||
stderr = new BufferStream$1(); | ||
@@ -774,3 +1475,3 @@ stdout = new BufferStream$1(); | ||
var args, error, output, pid, ref, ref1, ref2, ref3, signal, status, stderr, stdout; | ||
ref = parse(cmd, opts), cmd = ref[0], args = ref[1], opts = ref[2]; | ||
ref = parse$$1(cmd, opts), cmd = ref[0], args = ref[1], opts = ref[2]; | ||
ref3 = child_process.spawnSync(cmd, args, { | ||
@@ -777,0 +1478,0 @@ cwd: opts.cwd, |
{ | ||
"name": "executive", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Elegant command execution with built-in control flow", | ||
@@ -41,5 +41,2 @@ "main": "lib/executive.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"shell-quote": "1.6.1" | ||
}, | ||
"devDependencies": { | ||
@@ -54,4 +51,5 @@ "coffee-script": "1.12.5", | ||
"sake-version": "0.1.18", | ||
"shell-quote": "1.6.1", | ||
"vigil": "0.7.3" | ||
} | ||
} |
@@ -25,2 +25,3 @@ # executive | ||
- Easily blend commands, pure functions and promises with built-in control flow | ||
- No external dependencies | ||
@@ -27,0 +28,0 @@ ## Install |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
305424
0
3260
211
10
- Removedshell-quote@1.6.1
- Removedarray-filter@0.0.1(transitive)
- Removedarray-map@0.0.1(transitive)
- Removedarray-reduce@0.0.0(transitive)
- Removedjsonify@0.0.1(transitive)
- Removedshell-quote@1.6.1(transitive)