Comparing version 1.13.7 to 1.13.8
## History | ||
- v1.13.8 October 2, 2012 | ||
- `balUtilModules` changes: | ||
- Added `openProcess` and `closeProcess`, and using them in `spawn` and `exec`, used to prevent `EMFILE` errors when there are too many open processes | ||
- Max number of open processes is configurable via the `NODE_MAX_OPEN_PROCESSES` environment variable | ||
` balUtilPaths` changes: | ||
- Max number of open files is now configurable via the`NODE_MAX_OPEN_FILES` environment variable | ||
- v1.13.7 September 24, 2012 | ||
@@ -4,0 +11,0 @@ - `balUtilPaths` changes: |
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var balUtilFlow, balUtilModules, balUtilPaths, balUtilTypes, isWindows, | ||
var balUtilFlow, balUtilModules, balUtilPaths, balUtilTypes, isWindows, _ref, _ref1, _ref2, _ref3, | ||
__slice = [].slice; | ||
@@ -16,2 +16,14 @@ | ||
if ((_ref = global.numberOfOpenProcesses) == null) { | ||
global.numberOfOpenProcesses = 0; | ||
} | ||
if ((_ref1 = global.maxNumberOfOpenProcesses) == null) { | ||
global.maxNumberOfOpenProcesses = (_ref2 = process.env.NODE_MAX_OPEN_PROCESSES) != null ? _ref2 : 30; | ||
} | ||
if ((_ref3 = global.waitingToOpenProcessDelay) == null) { | ||
global.waitingToOpenProcessDelay = 100; | ||
} | ||
balUtilModules = { | ||
@@ -21,50 +33,74 @@ isWindows: function() { | ||
}, | ||
spawn: function(command, opts, next) { | ||
var err, pid, spawn, stderr, stdout, _ref; | ||
spawn = require('child_process').spawn; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
pid = null; | ||
err = null; | ||
stdout = ''; | ||
stderr = ''; | ||
if (balUtilTypes.isString(command)) { | ||
command = command.split(' '); | ||
openProcess: function(next) { | ||
if (global.numberOfOpenProcesses < 0) { | ||
throw new Error("balUtilModules.openProcess: the numberOfOpenProcesses is [" + global.numberOfOpenProcesses + "] which should be impossible..."); | ||
} | ||
if (balUtilTypes.isArray(command)) { | ||
pid = spawn(command[0], command.slice(1), opts); | ||
if (global.numberOfOpenProcesses >= global.maxNumberOfOpenProcesses) { | ||
setTimeout(function() { | ||
return balUtilModules.openProcess(next); | ||
}, global.waitingToOpenProcessDelay); | ||
} else { | ||
pid = spawn(command.command, command.args || [], command.options || opts); | ||
++global.numberOfOpenProcesses; | ||
next(); | ||
} | ||
pid.stdout.on('data', function(data) { | ||
var dataStr; | ||
dataStr = data.toString(); | ||
if (opts.output) { | ||
process.stdout.write(dataStr); | ||
return this; | ||
}, | ||
closeProcess: function(next) { | ||
--global.numberOfOpenProcesses; | ||
if (typeof next === "function") { | ||
next(); | ||
} | ||
return this; | ||
}, | ||
spawn: function(command, opts, next) { | ||
balUtilModules.openProcess(function() { | ||
var err, pid, spawn, stderr, stdout, _ref4; | ||
spawn = require('child_process').spawn; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
pid = null; | ||
err = null; | ||
stdout = ''; | ||
stderr = ''; | ||
if (balUtilTypes.isString(command)) { | ||
command = command.split(' '); | ||
} | ||
return stdout += dataStr; | ||
}); | ||
pid.stderr.on('data', function(data) { | ||
var dataStr; | ||
dataStr = data.toString(); | ||
if (opts.output) { | ||
process.stderr.write(dataStr); | ||
if (balUtilTypes.isArray(command)) { | ||
pid = spawn(command[0], command.slice(1), opts); | ||
} else { | ||
pid = spawn(command.command, command.args || [], command.options || opts); | ||
} | ||
return stderr += dataStr; | ||
}); | ||
pid.on('exit', function(code, signal) { | ||
err = null; | ||
if (code !== 0) { | ||
err = new Error(stderr || 'exited with a non-zero status code'); | ||
pid.stdout.on('data', function(data) { | ||
var dataStr; | ||
dataStr = data.toString(); | ||
if (opts.output) { | ||
process.stdout.write(dataStr); | ||
} | ||
return stdout += dataStr; | ||
}); | ||
pid.stderr.on('data', function(data) { | ||
var dataStr; | ||
dataStr = data.toString(); | ||
if (opts.output) { | ||
process.stderr.write(dataStr); | ||
} | ||
return stderr += dataStr; | ||
}); | ||
pid.on('exit', function(code, signal) { | ||
err = null; | ||
if (code !== 0) { | ||
err = new Error(stderr || 'exited with a non-zero status code'); | ||
} | ||
balUtilModules.closeProcess(); | ||
return next(err, stdout, stderr, code, signal); | ||
}); | ||
if (opts.stdin) { | ||
pid.stdin.write(opts.stdin); | ||
return pid.stdin.end(); | ||
} | ||
return next(err, stdout, stderr, code, signal); | ||
}); | ||
if (opts.stdin) { | ||
pid.stdin.write(opts.stdin); | ||
pid.stdin.end(); | ||
} | ||
return this; | ||
}, | ||
spawnMultiple: function(commands, opts, next) { | ||
var command, results, tasks, _i, _len, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var command, results, tasks, _i, _len, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
results = []; | ||
@@ -95,7 +131,10 @@ tasks = new balUtilFlow.Group(function(err) { | ||
exec: function(command, opts, next) { | ||
var exec, _ref; | ||
exec = require('child_process').exec; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
exec(command, opts, function(err, stdout, stderr) { | ||
return next(err, stdout, stderr); | ||
balUtilModules.openProcess(function() { | ||
var exec, _ref4; | ||
exec = require('child_process').exec; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
return exec(command, opts, function(err, stdout, stderr) { | ||
balUtilModules.closeProcess(); | ||
return next(err, stdout, stderr); | ||
}); | ||
}); | ||
@@ -105,4 +144,4 @@ return this; | ||
execMultiple: function(commands, opts, next) { | ||
var command, results, tasks, _i, _len, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var command, results, tasks, _i, _len, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
results = []; | ||
@@ -259,4 +298,4 @@ tasks = new balUtilFlow.Group(function(err) { | ||
gitCommand: function(command, opts, next) { | ||
var performSpawn, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var performSpawn, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
if (balUtilTypes.isString(command)) { | ||
@@ -285,4 +324,4 @@ command = command.split(' '); | ||
gitCommands: function(commands, opts, next) { | ||
var command, results, tasks, _i, _len, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var command, results, tasks, _i, _len, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
results = []; | ||
@@ -313,4 +352,4 @@ tasks = new balUtilFlow.Group(function(err) { | ||
nodeCommand: function(command, opts, next) { | ||
var performSpawn, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var performSpawn, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
if (balUtilTypes.isString(command)) { | ||
@@ -339,4 +378,4 @@ command = command.split(' '); | ||
nodeCommands: function(commands, opts, next) { | ||
var command, results, tasks, _i, _len, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var command, results, tasks, _i, _len, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
results = []; | ||
@@ -367,4 +406,4 @@ tasks = new balUtilFlow.Group(function(err) { | ||
npmCommand: function(command, opts, next) { | ||
var performSpawn, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var performSpawn, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
if (balUtilTypes.isString(command)) { | ||
@@ -393,4 +432,4 @@ command = command.split(' '); | ||
npmCommands: function(commands, opts, next) { | ||
var command, results, tasks, _i, _len, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var command, results, tasks, _i, _len, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
results = []; | ||
@@ -421,4 +460,4 @@ tasks = new balUtilFlow.Group(function(err) { | ||
initGitRepo: function(opts, next) { | ||
var branch, commands, gitPath, logger, output, path, remote, url, _ref; | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
var branch, commands, gitPath, logger, output, path, remote, url, _ref4; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
path = opts.path, remote = opts.remote, url = opts.url, branch = opts.branch, logger = opts.logger, output = opts.output, gitPath = opts.gitPath; | ||
@@ -447,5 +486,5 @@ commands = [['init'], ['remote', 'add', remote, url], ['fetch', remote], ['pull', remote, branch], ['submodule', 'init'], ['submodule', 'update', '--recursive']]; | ||
initNodeModules: function(opts, next) { | ||
var force, logger, nodeModulesPath, packageJsonPath, partTwo, path, pathUtil, _ref; | ||
var force, logger, nodeModulesPath, packageJsonPath, partTwo, path, pathUtil, _ref4; | ||
pathUtil = require('path'); | ||
_ref = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref[0], next = _ref[1]; | ||
_ref4 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref4[0], next = _ref4[1]; | ||
path = opts.path, logger = opts.logger, force = opts.force; | ||
@@ -452,0 +491,0 @@ opts.cwd = path; |
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var balUtilFlow, balUtilPaths, balUtilTypes, fsUtil, pathUtil, _ref, _ref1, _ref2, | ||
var balUtilFlow, balUtilPaths, balUtilTypes, fsUtil, pathUtil, _ref, _ref1, _ref2, _ref3, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, | ||
@@ -21,6 +21,6 @@ __slice = [].slice, | ||
if ((_ref1 = global.maxNumberOfOpenFiles) == null) { | ||
global.maxNumberOfOpenFiles = 100; | ||
global.maxNumberOfOpenFiles = (_ref2 = process.env.NODE_MAX_OPEN_FILES) != null ? _ref2 : 100; | ||
} | ||
if ((_ref2 = global.waitingToOpenFileDelay) == null) { | ||
if ((_ref3 = global.waitingToOpenFileDelay) == null) { | ||
global.waitingToOpenFileDelay = 100; | ||
@@ -183,3 +183,3 @@ } | ||
getEncodingSync: function(buffer, opts) { | ||
var binaryEncoding, charCode, chunkBegin, chunkEnd, chunkLength, contentChunkUTF8, encoding, i, textEncoding, _i, _ref3; | ||
var binaryEncoding, charCode, chunkBegin, chunkEnd, chunkLength, contentChunkUTF8, encoding, i, textEncoding, _i, _ref4; | ||
textEncoding = 'utf8'; | ||
@@ -218,3 +218,3 @@ binaryEncoding = 'binary'; | ||
encoding = textEncoding; | ||
for (i = _i = 0, _ref3 = contentChunkUTF8.length; 0 <= _ref3 ? _i < _ref3 : _i > _ref3; i = 0 <= _ref3 ? ++_i : --_i) { | ||
for (i = _i = 0, _ref4 = contentChunkUTF8.length; 0 <= _ref4 ? _i < _ref4 : _i > _ref4; i = 0 <= _ref4 ? ++_i : --_i) { | ||
charCode = contentChunkUTF8.charCodeAt(i); | ||
@@ -331,3 +331,3 @@ if (charCode === 65533 || charCode <= 8) { | ||
scandir: function() { | ||
var args, err, list, options, tasks, tree, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8; | ||
var args, err, list, options, tasks, tree, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
@@ -353,19 +353,19 @@ list = {}; | ||
} | ||
if ((_ref3 = options.recurse) == null) { | ||
if ((_ref4 = options.recurse) == null) { | ||
options.recurse = true; | ||
} | ||
if ((_ref4 = options.readFiles) == null) { | ||
if ((_ref5 = options.readFiles) == null) { | ||
options.readFiles = false; | ||
} | ||
if ((_ref5 = options.ignoreHiddenFiles) == null) { | ||
if ((_ref6 = options.ignoreHiddenFiles) == null) { | ||
options.ignoreHiddenFiles = false; | ||
} | ||
if ((_ref6 = options.ignorePatterns) == null) { | ||
if ((_ref7 = options.ignorePatterns) == null) { | ||
options.ignorePatterns = false; | ||
} | ||
if (options.action != null) { | ||
if ((_ref7 = options.fileAction) == null) { | ||
if ((_ref8 = options.fileAction) == null) { | ||
options.fileAction = options.action; | ||
} | ||
if ((_ref8 = options.dirAction) == null) { | ||
if ((_ref9 = options.dirAction) == null) { | ||
options.dirAction = options.action; | ||
@@ -518,6 +518,6 @@ } | ||
cpdir: function() { | ||
var args, err, ignoreHiddenFiles, ignorePatterns, next, outPath, scandirOptions, srcPath, _ref3; | ||
var args, err, ignoreHiddenFiles, ignorePatterns, next, outPath, scandirOptions, srcPath, _ref4; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
if (args.length === 1) { | ||
_ref3 = args[0], srcPath = _ref3.srcPath, outPath = _ref3.outPath, next = _ref3.next, ignoreHiddenFiles = _ref3.ignoreHiddenFiles, ignorePatterns = _ref3.ignorePatterns; | ||
_ref4 = args[0], srcPath = _ref4.srcPath, outPath = _ref4.outPath, next = _ref4.next, ignoreHiddenFiles = _ref4.ignoreHiddenFiles, ignorePatterns = _ref4.ignorePatterns; | ||
} else if (args.length >= 3) { | ||
@@ -563,6 +563,6 @@ srcPath = args[0], outPath = args[1], next = args[2]; | ||
rpdir: function() { | ||
var args, err, ignoreHiddenFiles, ignorePatterns, next, outPath, scandirOptions, srcPath, _ref3; | ||
var args, err, ignoreHiddenFiles, ignorePatterns, next, outPath, scandirOptions, srcPath, _ref4; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
if (args.length === 1) { | ||
_ref3 = args[0], srcPath = _ref3.srcPath, outPath = _ref3.outPath, next = _ref3.next, ignoreHiddenFiles = _ref3.ignoreHiddenFiles, ignorePatterns = _ref3.ignorePatterns; | ||
_ref4 = args[0], srcPath = _ref4.srcPath, outPath = _ref4.outPath, next = _ref4.next, ignoreHiddenFiles = _ref4.ignoreHiddenFiles, ignorePatterns = _ref4.ignorePatterns; | ||
} else if (args.length >= 3) { | ||
@@ -569,0 +569,0 @@ srcPath = args[0], outPath = args[1], next = args[2]; |
{ | ||
"name": "bal-util", | ||
"version": "1.13.7", | ||
"version": "1.13.8", | ||
"description": "Common utility functions for Node.js used and maintained by Benjamin Lupton", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/balupton/bal-util", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
96233
2323
40