diff --git a/.gitignore b/.gitignore
index 7dccd97..63d3f1b 100755
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,6 @@ logs
results
node_modules
-npm-debug.log
\ No newline at end of file
+npm-debug.log
+
+out/
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
index 3b8f63c..82dc914 100755
--- a/.npmignore
+++ b/.npmignore
@@ -4,4 +4,5 @@ Makefile
History.md
src/
-out/test/
\ No newline at end of file
+out/test/
+test/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 075f27a..527e6ee 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,8 @@
language: node_js
install: "npm install"
before_script: "./node_modules/.bin/cake test-prepare"
-script: "./node_modules/.bin/cake test"
+script: "npm test"
node_js:
- - "0.4"
- - "0.6"
- "0.8"
- "0.10"
notifications:
diff --git a/Cakefile b/Cakefile
index 2ffaddb..1fb58ca 100644
--- a/Cakefile
+++ b/Cakefile
@@ -49,11 +49,11 @@ clean = (opts,next) ->
compile = (opts,next) ->
(next = opts; opts = {}) unless next?
- spawn(COFFEE, ['-co', OUT, SRC], {stdio:'inherit',cwd:APP}).on('exit',next)
+ spawn(COFFEE, ['-bco', OUT, SRC], {stdio:'inherit',cwd:APP}).on('exit',next)
watch = (opts,next) ->
(next = opts; opts = {}) unless next?
- spawn(COFFEE, ['-wco', OUT, SRC], {stdio:'inherit',cwd:APP}).on('exit',next)
+ spawn(COFFEE, ['-bwco', OUT, SRC], {stdio:'inherit',cwd:APP}).on('exit',next)
install = (opts,next) ->
(next = opts; opts = {}) unless next?
diff --git a/History.md b/History.md
index e13ecac..8f4d2ed 100755
--- a/History.md
+++ b/History.md
@@ -1,5 +1,10 @@
## History
+- v1.16.14 March 27, 2013
+ - Killed explicit browser support, use [Browserify](http://browserify.org/) instead
+ - Removed the `out` directory from git
+ - Now compiled with the coffee-script bare option
+
- v1.16.13 March 23, 2013
- `balUtilEvents` changes:
- `EventEmitterEnhanced` changes:
diff --git a/README.md b/README.md
index 1f13d63..b22f4ad 100755
--- a/README.md
+++ b/README.md
@@ -1,23 +1,22 @@
# Balupton's Utility Functions [![Build Status](https://secure.travis-ci.org/balupton/bal-util.png?branch=master)](http://travis-ci.org/balupton/bal-util)
-This project nutures plenty of JavaScript and Node.js utility functions used and maintained by Benjamin Lupton
+Common utility functions for Node.js used and maintained by Benjamin Lupton
-## What it provides
-Look at its source code. It's reasonbly documented, and there's lots of tests!
+## Install
+### Backend
-## Installing
-
-### Node
1. [Install Node.js](http://bevry.me/node/install)
-2. Install it: `npm install bal-util`
+2. `npm install --save bal-util`
+
+### Frontend
+
+1. [See Browserify](http://browserify.org/)
-### Browser
-Include the scripts as you would normally.
-## Using
-Best off looking at the tests, or reading the inline comments. [However, if you like wiki documentation, feel free to write it here!](https://github.com/balupton/bal-util/wiki)
+## Usage
+Best off looking at source, it's well documented, and there are plenty of tests
## History
@@ -26,4 +25,4 @@ You can discover the history inside the [History.md](https://github.com/balupton
## License
Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/)
-
Copyright © 2011+ [Benjamin Arthur Lupton](http://balupton.com)
+
Copyright © 2011+ [Benjamin Arthur Lupton](http://balupton.com)
diff --git a/out/lib/balutil.js b/out/lib/balutil.js
deleted file mode 100644
index 910d53f..0000000
--- a/out/lib/balutil.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var balUtil, balUtilCompare, balUtilEvents, balUtilFlow, balUtilHTML, balUtilModules, balUtilPaths, balUtilTypes, key, subpackage, subpackages, value, _i, _len,
- __hasProp = {}.hasOwnProperty;
-
- balUtil = {};
-
- balUtilCompare = require('./compare.js');
-
- balUtilEvents = require('./events');
-
- balUtilFlow = require('./flow');
-
- balUtilHTML = require('./html');
-
- balUtilModules = require('./modules');
-
- balUtilPaths = require('./paths');
-
- balUtilTypes = require('./types');
-
- subpackages = [balUtilCompare, balUtilEvents, balUtilFlow, balUtilHTML, balUtilModules, balUtilPaths, balUtilTypes];
-
- for (_i = 0, _len = subpackages.length; _i < _len; _i++) {
- subpackage = subpackages[_i];
- for (key in subpackage) {
- if (!__hasProp.call(subpackage, key)) continue;
- value = subpackage[key];
- balUtil[key] = value;
- }
- }
-
- module.exports = balUtil;
-
-}).call(this);
diff --git a/out/lib/compare.js b/out/lib/compare.js
deleted file mode 100644
index 066f03c..0000000
--- a/out/lib/compare.js
+++ /dev/null
@@ -1,144 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var balUtilCompare, balUtilPaths;
-
- balUtilCompare = null;
-
- balUtilPaths = require('./paths');
-
- balUtilCompare = {
- versionCompare: function(v1, operator, v2) {
- var compare, i, numVersion, prepVersion, result, vm, x, _i;
-
- i = x = compare = 0;
- vm = {
- 'dev': -6,
- 'alpha': -5,
- 'a': -5,
- 'beta': -4,
- 'b': -4,
- 'RC': -3,
- 'rc': -3,
- '#': -2,
- 'p': -1,
- 'pl': -1
- };
- prepVersion = function(v) {
- v = ('' + v).replace(/[_\-+]/g, '.');
- v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.');
- if (!v.length) {
- return [-8];
- } else {
- return v.split('.');
- }
- };
- numVersion = function(v) {
- if (!v) {
- return 0;
- } else {
- if (isNaN(v)) {
- return vm[v] || -7;
- } else {
- return parseInt(v, 10);
- }
- }
- };
- v1 = prepVersion(v1);
- v2 = prepVersion(v2);
- x = Math.max(v1.length, v2.length);
- for (i = _i = 0; 0 <= x ? _i <= x : _i >= x; i = 0 <= x ? ++_i : --_i) {
- if (v1[i] === v2[i]) {
- continue;
- }
- v1[i] = numVersion(v1[i]);
- v2[i] = numVersion(v2[i]);
- if (v1[i] < v2[i]) {
- compare = -1;
- break;
- } else if (v1[i] > v2[i]) {
- compare = 1;
- break;
- }
- }
- if (!operator) {
- return compare;
- }
- result = (function() {
- switch (operator) {
- case '>':
- case 'gt':
- return compare > 0;
- case '>=':
- case 'ge':
- return compare >= 0;
- case '<=':
- case 'le':
- return compare <= 0;
- case '==':
- case '=':
- case 'eq':
- case 'is':
- return compare === 0;
- case '<>':
- case '!=':
- case 'ne':
- case 'isnt':
- return compare !== 0;
- case '':
- case '<':
- case 'lt':
- return compare < 0;
- default:
- return null;
- }
- })();
- return result;
- },
- packageCompare: function(_arg) {
- var details, errorCallback, local, newVersionCallback, oldVersionCallback, remote, runCompare, sameVersionCallback;
-
- local = _arg.local, remote = _arg.remote, newVersionCallback = _arg.newVersionCallback, sameVersionCallback = _arg.sameVersionCallback, oldVersionCallback = _arg.oldVersionCallback, errorCallback = _arg.errorCallback;
- details = {};
- runCompare = function() {
- if (balUtilCompare.versionCompare(details.local.version, '<', details.remote.version)) {
- return typeof newVersionCallback === "function" ? newVersionCallback(details) : void 0;
- } else if (balUtilCompare.versionCompare(details.local.version, '==', details.remote.version)) {
- return typeof sameVersionCallback === "function" ? sameVersionCallback(details) : void 0;
- } else if (balUtilCompare.versionCompare(details.local.version, '>', details.remote.version)) {
- return typeof oldVersionCallback === "function" ? oldVersionCallback(details) : void 0;
- }
- };
- balUtilPaths.readPath(local, function(err, data) {
- var dataStr;
-
- if (err) {
- return typeof errorCallback === "function" ? errorCallback(err, data) : void 0;
- }
- try {
- dataStr = data.toString();
- details.local = JSON.parse(dataStr);
- } catch (_error) {
- err = _error;
- return typeof errorCallback === "function" ? errorCallback(err, data) : void 0;
- }
- return balUtilPaths.readPath(remote, function(err, data) {
- if (err) {
- return typeof errorCallback === "function" ? errorCallback(err, data) : void 0;
- }
- try {
- dataStr = data.toString();
- details.remote = JSON.parse(dataStr);
- } catch (_error) {
- err = _error;
- return typeof errorCallback === "function" ? errorCallback(err, data) : void 0;
- }
- return runCompare();
- });
- });
- return this;
- }
- };
-
- module.exports = balUtilCompare;
-
-}).call(this);
diff --git a/out/lib/events.js b/out/lib/events.js
deleted file mode 100644
index 13f1b81..0000000
--- a/out/lib/events.js
+++ /dev/null
@@ -1,313 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var Event, EventEmitter, EventEmitterEnhanced, EventSystem, balUtilFlow, balUtilTypes, debug, _ref, _ref1,
- __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- __slice = [].slice;
-
- EventEmitter = require('events').EventEmitter;
-
- balUtilFlow = require('./flow');
-
- balUtilTypes = require('./types');
-
- debug = false;
-
- EventEmitterEnhanced = (function(_super) {
- __extends(EventEmitterEnhanced, _super);
-
- function EventEmitterEnhanced() {
- _ref = EventEmitterEnhanced.__super__.constructor.apply(this, arguments);
- return _ref;
- }
-
- EventEmitterEnhanced.prototype.getListenerGroup = function(eventName, data, next) {
- var listeners, me, tasks;
-
- me = this;
- listeners = this.listeners(eventName);
- tasks = new balUtilFlow.Group(next);
- balUtilFlow.each(listeners, function(listener) {
- if (listener.listener) {
- listener = [listener, listener.listener];
- }
- return tasks.push(function(complete) {
- return balUtilFlow.fireWithOptionalCallback(listener, [data, complete], me);
- });
- });
- return tasks;
- };
-
- EventEmitterEnhanced.prototype.emitSync = function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return this.emitSerial.apply(this, args);
- };
-
- EventEmitterEnhanced.prototype.emitSerial = function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return this.getListenerGroup.apply(this, args).run('serial');
- };
-
- EventEmitterEnhanced.prototype.emitAsync = function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return this.emitParallel.apply(this, args);
- };
-
- EventEmitterEnhanced.prototype.emitParallel = function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return this.getListenerGroup.apply(this, args).run('parallel');
- };
-
- return EventEmitterEnhanced;
-
- })(EventEmitter);
-
- Event = (function() {
- Event.prototype.name = null;
-
- Event.prototype.locked = false;
-
- Event.prototype.finished = false;
-
- function Event(_arg) {
- this.name = _arg.name;
- }
-
- return Event;
-
- })();
-
- EventSystem = (function(_super) {
- __extends(EventSystem, _super);
-
- function EventSystem() {
- _ref1 = EventSystem.__super__.constructor.apply(this, arguments);
- return _ref1;
- }
-
- EventSystem.prototype._eventSystemEvents = null;
-
- EventSystem.prototype.event = function(eventName) {
- var _base;
-
- this._eventSystemEvents || (this._eventSystemEvents = {});
- return (_base = this._eventSystemEvents)[eventName] || (_base[eventName] = new Event(eventName));
- };
-
- EventSystem.prototype.lock = function(eventName, next) {
- var err, event,
- _this = this;
-
- event = this.event(eventName);
- if (event.locked === false) {
- event.locked = true;
- try {
- this.emit(eventName + ':locked');
- } catch (_error) {
- err = _error;
- next(err);
- return this;
- } finally {
- next();
- }
- } else {
- this.onceUnlocked(eventName, function(err) {
- if (err) {
- return next(err);
- }
- return _this.lock(eventName, next);
- });
- }
- return this;
- };
-
- EventSystem.prototype.unlock = function(eventName, next) {
- var err, event;
-
- event = this.event(eventName);
- event.locked = false;
- try {
- this.emit(eventName + ':unlocked');
- } catch (_error) {
- err = _error;
- next(err);
- return this;
- } finally {
- next();
- }
- return this;
- };
-
- EventSystem.prototype.start = function(eventName, next) {
- var _this = this;
-
- this.lock(eventName, function(err) {
- var event;
-
- if (err) {
- return next(err);
- }
- event = _this.event(eventName);
- event.finished = false;
- try {
- return _this.emit(eventName + ':started');
- } catch (_error) {
- err = _error;
- next(err);
- return _this;
- } finally {
- next();
- }
- });
- return this;
- };
-
- EventSystem.prototype.finish = function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return this.finished.apply(this, args);
- };
-
- EventSystem.prototype.finished = function(eventName, next) {
- var event,
- _this = this;
-
- event = this.event(eventName);
- event.finished = true;
- this.unlock(eventName, function(err) {
- if (err) {
- return next(err);
- }
- try {
- return _this.emit(eventName + ':finished');
- } catch (_error) {
- err = _error;
- next(err);
- return _this;
- } finally {
- next();
- }
- });
- return this;
- };
-
- EventSystem.prototype.onceUnlocked = function(eventName, next) {
- var event;
-
- event = this.event(eventName);
- if (event.locked) {
- this.once(eventName + ':unlocked', next);
- } else {
- next();
- }
- return this;
- };
-
- EventSystem.prototype.onceFinished = function(eventName, next) {
- var event;
-
- event = this.event(eventName);
- if (event.finished) {
- next();
- } else {
- this.once(eventName + ':finished', next);
- }
- return this;
- };
-
- EventSystem.prototype.whenFinished = function(eventName, next) {
- var event;
-
- event = this.event(eventName);
- if (event.finished) {
- next();
- }
- this.on(eventName + ':finished', next);
- return this;
- };
-
- EventSystem.prototype.when = function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return this.on.apply(this, args);
- };
-
- EventSystem.prototype.block = function(eventNames, next) {
- var done, err, eventName, total, _i, _len;
-
- if (!balUtilTypes.isArray(eventNames)) {
- if (balUtilTypes.isString(eventNames)) {
- eventNames = eventNames.split(/[,\s]+/g);
- } else {
- err = new Error('Unknown eventNames type');
- return next(err);
- }
- }
- total = eventNames.length;
- done = 0;
- for (_i = 0, _len = eventNames.length; _i < _len; _i++) {
- eventName = eventNames[_i];
- this.lock(eventName, function(err) {
- if (err) {
- done = total;
- return next(err);
- }
- done++;
- if (done === total) {
- return next();
- }
- });
- }
- return this;
- };
-
- EventSystem.prototype.unblock = function(eventNames, next) {
- var done, err, eventName, total, _i, _len;
-
- if (!balUtilTypes.isArray(eventNames)) {
- if (balUtilTypes.isString(eventNames)) {
- eventNames = eventNames.split(/[,\s]+/g);
- } else {
- err = new Error('Unknown eventNames type');
- return next(err);
- }
- }
- total = eventNames.length;
- done = 0;
- for (_i = 0, _len = eventNames.length; _i < _len; _i++) {
- eventName = eventNames[_i];
- this.unlock(eventName, function(err) {
- if (err) {
- done = total;
- return next(err);
- }
- done++;
- if (done === total) {
- return next();
- }
- });
- }
- return this;
- };
-
- return EventSystem;
-
- })(EventEmitterEnhanced);
-
- module.exports = {
- EventEmitterEnhanced: EventEmitterEnhanced,
- Event: Event,
- EventSystem: EventSystem
- };
-
-}).call(this);
diff --git a/out/lib/flow.js b/out/lib/flow.js
deleted file mode 100644
index b03b7ac..0000000
--- a/out/lib/flow.js
+++ /dev/null
@@ -1,784 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var balUtilFlow, balUtilTypes,
- __slice = [].slice,
- __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
-
- balUtilTypes = (typeof require === "function" ? require('./types') : void 0) || this.balUtilTypes;
-
- balUtilFlow = {
- wait: function(delay, fn) {
- return setTimeout(fn, delay);
- },
- extractOptsAndCallback: function(opts, next) {
- if (balUtilTypes.isFunction(opts) && (next != null) === false) {
- next = opts;
- opts = {};
- } else {
- opts || (opts = {});
- }
- next || (next = opts.next || null);
- return [opts, next];
- },
- fireWithOptionalCallback: function(method, args, context) {
- var callback, caughtError, err, fireMethod, introspectMethod, result;
-
- args || (args = []);
- callback = args[args.length - 1];
- context || (context = null);
- result = null;
- if (balUtilTypes.isArray(method)) {
- fireMethod = method[0], introspectMethod = method[1];
- } else {
- fireMethod = introspectMethod = method;
- }
- if (introspectMethod.length === args.length) {
- try {
- result = fireMethod.apply(context, args);
- } catch (_error) {
- caughtError = _error;
- callback(caughtError);
- }
- } else {
- err = null;
- try {
- result = fireMethod.apply(context, args);
- if (balUtilTypes.isError(result)) {
- err = result;
- }
- } catch (_error) {
- caughtError = _error;
- err = caughtError;
- }
- callback(err, result);
- }
- return result;
- },
- clone: function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- args.unshift({});
- return this.shallowExtendPlainObjects.apply(this, args);
- },
- deepClone: function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- args.unshift({});
- return this.deepExtendPlainObjects.apply(this, args);
- },
- extend: function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return this.shallowExtendPlainObjects.apply(this, args);
- },
- shallowExtendPlainObjects: function() {
- var key, obj, objs, target, value, _i, _len;
-
- target = arguments[0], objs = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- for (_i = 0, _len = objs.length; _i < _len; _i++) {
- obj = objs[_i];
- obj || (obj = {});
- for (key in obj) {
- if (!__hasProp.call(obj, key)) continue;
- value = obj[key];
- target[key] = value;
- }
- }
- return target;
- },
- safeShallowExtendPlainObjects: function() {
- var key, obj, objs, target, value, _i, _len;
-
- target = arguments[0], objs = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- for (_i = 0, _len = objs.length; _i < _len; _i++) {
- obj = objs[_i];
- obj || (obj = {});
- for (key in obj) {
- if (!__hasProp.call(obj, key)) continue;
- value = obj[key];
- if (value == null) {
- continue;
- }
- target[key] = value;
- }
- }
- return target;
- },
- deepExtendPlainObjects: function() {
- var key, obj, objs, target, value, _i, _len;
-
- target = arguments[0], objs = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- for (_i = 0, _len = objs.length; _i < _len; _i++) {
- obj = objs[_i];
- obj || (obj = {});
- for (key in obj) {
- if (!__hasProp.call(obj, key)) continue;
- value = obj[key];
- if (balUtilTypes.isPlainObject(value)) {
- if (!balUtilTypes.isPlainObject(target[key])) {
- target[key] = {};
- }
- balUtilFlow.deepExtendPlainObjects(target[key], value);
- } else {
- target[key] = value;
- }
- }
- }
- return target;
- },
- safeDeepExtendPlainObjects: function() {
- var key, obj, objs, target, value, _i, _len;
-
- target = arguments[0], objs = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- for (_i = 0, _len = objs.length; _i < _len; _i++) {
- obj = objs[_i];
- obj || (obj = {});
- for (key in obj) {
- if (!__hasProp.call(obj, key)) continue;
- value = obj[key];
- if (value == null) {
- continue;
- }
- if (balUtilTypes.isPlainObject(value)) {
- if (!balUtilTypes.isPlainObject(target[key])) {
- target[key] = {};
- }
- balUtilFlow.safeDeepExtendPlainObjects(target[key], value);
- } else {
- target[key] = value;
- }
- }
- }
- return target;
- },
- dereference: function(source) {
- var target;
-
- target = JSON.parse(JSON.stringify(source));
- return target;
- },
- each: function(obj, callback, context) {
- var item, key, _i, _len;
-
- context || (context = obj);
- if (balUtilTypes.isArray(obj)) {
- for (key = _i = 0, _len = obj.length; _i < _len; key = ++_i) {
- item = obj[key];
- if (callback.call(context, item, key, obj) === false) {
- break;
- }
- }
- } else {
- for (key in obj) {
- if (!__hasProp.call(obj, key)) continue;
- item = obj[key];
- if (callback.call(context, item, key, obj) === false) {
- break;
- }
- }
- }
- return this;
- },
- flow: function() {
- var action, actions, args, next, object, tasks, _ref, _ref1, _ref2;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (args.length === 1) {
- _ref = args[0], object = _ref.object, actions = _ref.actions, action = _ref.action, args = _ref.args, tasks = _ref.tasks, next = _ref.next;
- } else if (args.length === 4) {
- _ref1 = args, object = _ref1[0], action = _ref1[1], args = _ref1[2], next = _ref1[3];
- } else if (args.length === 3) {
- _ref2 = args, actions = _ref2[0], args = _ref2[1], next = _ref2[2];
- }
- if ((action != null) === false && (actions != null) === false) {
- throw new Error('balUtilFlow.flow called without any action');
- }
- if (actions == null) {
- actions = action.split(/[,\s]+/g);
- }
- if (object == null) {
- object = global;
- }
- tasks || (tasks = new balUtilFlow.Group(next));
- balUtilFlow.each(actions, function(action) {
- return tasks.push(function(complete) {
- var argsClone, fn;
-
- argsClone = (args || []).slice();
- argsClone.push(complete);
- fn = balUtilTypes.isFunction(action) ? action : object[action];
- return fn.apply(object, argsClone);
- });
- });
- tasks.sync();
- return this;
- },
- createSnore: function(message, opts) {
- var snore, _ref;
-
- opts || (opts = {});
- if ((_ref = opts.delay) == null) {
- opts.delay = 5000;
- }
- snore = {
- snoring: false,
- timer: setTimeout(function() {
- snore.clear();
- snore.snoring = true;
- return typeof message === "function" ? message() : void 0;
- }, opts.delay),
- clear: function() {
- if (snore.timer) {
- clearTimeout(snore.timer);
- return snore.timer = false;
- }
- }
- };
- return snore;
- },
- suffixArray: function() {
- var arg, args, item, result, suffix, _i, _j, _len, _len1;
-
- suffix = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- result = [];
- for (_i = 0, _len = args.length; _i < _len; _i++) {
- arg = args[_i];
- if (!balUtilTypes.isArray(arg)) {
- arg = [arg];
- }
- for (_j = 0, _len1 = arg.length; _j < _len1; _j++) {
- item = arg[_j];
- result.push(item + suffix);
- }
- }
- return result;
- },
- setDeep: function(location, keys, value, safe) {
- var key, result, _ref, _ref1, _ref2;
-
- if (safe == null) {
- safe = false;
- }
- if (!balUtilTypes.isArray(keys)) {
- keys = keys.split('.');
- }
- if (keys.length === 0) {
- return void 0;
- }
- if (keys.length === 0 || typeof location === 'undefined') {
- result = void 0;
- } else if (location === null) {
- result = null;
- } else {
- key = keys[0];
- location = (_ref = location.attributes) != null ? _ref : location;
- if (keys.length === 1) {
- if (safe) {
- if ((_ref1 = location[key]) == null) {
- location[key] = value;
- }
- } else {
- if (typeof value === 'undefined') {
- if (typeof location[key] !== 'undefined') {
- delete location[key];
- }
- } else {
- location[key] = value;
- }
- }
- result = location[key];
- } else {
- location = (_ref2 = location[key]) != null ? _ref2 : location[key] = {};
- result = balUtilFlow.setDeep(location, keys.slice(1), value, safe);
- }
- }
- return result;
- },
- getDeep: function(location, keys) {
- var key, result, _ref;
-
- if (!balUtilTypes.isArray(keys)) {
- keys = keys.split('.');
- }
- if (keys.length === 0 || typeof location === 'undefined') {
- result = void 0;
- } else if (location === null) {
- result = null;
- } else {
- key = keys[0];
- location = (_ref = location.attributes) != null ? _ref : location;
- location = typeof location[key] === 'undefined' ? void 0 : location[key];
- if (keys.length === 1) {
- result = location;
- } else {
- result = balUtilFlow.getDeep(location, keys.slice(1));
- }
- }
- return result;
- }
- };
-
- /*
- Usage:
- # Add tasks to a queue then fire them in parallel (asynchronously)
- tasks = new Group (err) -> next err
- tasks.push (complete) -> someAsyncFunction(arg1, arg2, complete)
- tasks.push (complete) -> anotherAsyncFunction(arg1, arg2, complete)
- tasks.run()
-
- # Add tasks to a queue then fire them in serial (synchronously)
- tasks = new Group (err) -> next err
- tasks.push (complete) -> someAsyncFunction(arg1, arg2, complete)
- tasks.push (complete) -> anotherAsyncFunction(arg1, arg2, complete)
- tasks.run('serial')
- */
-
-
- balUtilFlow.Group = (function() {
- _Class.prototype.total = 0;
-
- _Class.prototype.completed = 0;
-
- _Class.prototype.running = 0;
-
- _Class.prototype.exited = false;
-
- _Class.prototype.breakOnError = true;
-
- _Class.prototype.autoClear = false;
-
- _Class.prototype.queue = [];
-
- _Class.prototype.mode = 'parallel';
-
- _Class.prototype.lastResult = null;
-
- _Class.prototype.results = [];
-
- _Class.prototype.errors = [];
-
- _Class.prototype.next = function() {
- throw new Error('Groups require a completion callback');
- };
-
- function _Class() {
- var arg, args, autoClear, breakOnError, mode, next, _i, _len;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- this.clear();
- for (_i = 0, _len = args.length; _i < _len; _i++) {
- arg = args[_i];
- if (balUtilTypes.isString(arg)) {
- if (arg === 'serial' || arg === 'sync') {
- this.mode = 'serial';
- }
- } else if (balUtilTypes.isFunction(arg)) {
- this.next = arg;
- } else if (balUtilTypes.isObject(arg)) {
- next = arg.next, mode = arg.mode, breakOnError = arg.breakOnError, autoClear = arg.autoClear;
- if (next) {
- this.next = next;
- }
- if (mode) {
- this.mode = mode;
- }
- if (breakOnError) {
- this.breakOnError = breakOnError;
- }
- if (autoClear) {
- this.autoClear = autoClear;
- }
- } else {
- throw new Error('Unknown argument sent to Groups constructor');
- }
- }
- }
-
- _Class.prototype.clear = function() {
- this.total = 0;
- this.completed = 0;
- this.running = 0;
- this.exited = false;
- this.queue = [];
- this.results = [];
- this.errors = [];
- this.lastResult = null;
- return this;
- };
-
- _Class.prototype.hasTasks = function() {
- return this.queue.length !== 0;
- };
-
- _Class.prototype.hasCompleted = function() {
- return this.total !== 0 && this.total === this.completed;
- };
-
- _Class.prototype.isRunning = function() {
- return this.running !== 0;
- };
-
- _Class.prototype.hasExited = function(value) {
- if (value != null) {
- this.exited = value;
- }
- return this.exited === true;
- };
-
- _Class.prototype.logError = function(err) {
- if (this.errors[this.errors.length - 1] !== err) {
- this.errors.push(err);
- }
- return this;
- };
-
- _Class.prototype.complete = function() {
- var args, err;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- err = args[0] || void 0;
- this.lastResult = args;
- if (err) {
- this.logError(err);
- }
- this.results.push(args);
- if (this.running !== 0) {
- --this.running;
- }
- if (this.hasExited()) {
-
- } else {
- if (err && this.breakOnError) {
- this.exit();
- } else {
- ++this.completed;
- if (this.hasTasks()) {
- this.nextTask();
- } else if (this.isRunning() === false && this.hasCompleted()) {
- this.exit();
- }
- }
- }
- return this;
- };
-
- _Class.prototype.completer = function() {
- var _this = this;
-
- return function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return _this.complete.apply(_this, args);
- };
- };
-
- _Class.prototype.exit = function(err) {
- var errors, lastResult, results;
-
- if (err == null) {
- err = null;
- }
- if (err) {
- this.logError(err);
- }
- if (this.hasExited()) {
-
- } else {
- lastResult = this.lastResult;
- results = this.results;
- if (this.errors.length === 0) {
- errors = null;
- } else if (this.errors.length === 1) {
- errors = this.errors[0];
- } else {
- errors = this.errors;
- }
- if (this.autoClear) {
- this.clear();
- } else {
- this.hasExited(true);
- }
- this.next(errors, lastResult, results);
- }
- return this;
- };
-
- _Class.prototype.tasks = function(tasks) {
- var task, _i, _len;
-
- for (_i = 0, _len = tasks.length; _i < _len; _i++) {
- task = tasks[_i];
- this.push(task);
- }
- return this;
- };
-
- _Class.prototype.push = function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- ++this.total;
- this.queue.push(args);
- return this;
- };
-
- _Class.prototype.pushAndRun = function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (this.mode === 'serial' && this.isRunning()) {
- this.push.apply(this, args);
- } else {
- ++this.total;
- this.runTask(args);
- }
- return this;
- };
-
- _Class.prototype.nextTask = function() {
- var task;
-
- if (this.hasTasks()) {
- task = this.queue.shift();
- this.runTask(task);
- }
- return this;
- };
-
- _Class.prototype.runTask = function(task) {
- var err, me, run;
-
- me = this;
- try {
- run = function() {
- var complete, _context, _task;
-
- ++me.running;
- complete = me.completer();
- if (balUtilTypes.isArray(task)) {
- if (task.length === 2) {
- _context = task[0];
- _task = task[1];
- } else if (task.length === 1) {
- _task = task[0];
- _context = null;
- } else {
- throw new Error('balUtilFlow.Group an invalid task was pushed');
- }
- } else {
- _task = task;
- }
- return balUtilFlow.fireWithOptionalCallback(_task, [complete], _context);
- };
- if (this.completed !== 0 && (this.mode === 'parallel' || (this.completed % 100) === 0)) {
- setTimeout(run, 0);
- } else {
- run();
- }
- } catch (_error) {
- err = _error;
- this.complete(err);
- }
- return this;
- };
-
- _Class.prototype.run = function(mode) {
- var task, _i, _len, _ref, _ref1;
-
- if (this.isRunning() === false) {
- if (mode) {
- this.mode = mode;
- }
- this.hasExited(false);
- if (this.hasTasks()) {
- if ((_ref = this.mode) === 'serial' || _ref === 'sync') {
- this.nextTask();
- } else {
- _ref1 = this.queue;
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- task = _ref1[_i];
- this.nextTask();
- }
- }
- } else {
- this.exit();
- }
- }
- return this;
- };
-
- _Class.prototype.async = function() {
- return this.parallel();
- };
-
- _Class.prototype.parallel = function() {
- this.run('parallel');
- return this;
- };
-
- _Class.prototype.sync = function() {
- return this.serial();
- };
-
- _Class.prototype.serial = function() {
- this.run('serial');
- return this;
- };
-
- return _Class;
-
- })();
-
- balUtilFlow.Block = (function(_super) {
- __extends(_Class, _super);
-
- _Class.prototype.blockBefore = function(block) {};
-
- _Class.prototype.blockAfter = function(block, err) {};
-
- _Class.prototype.blockTaskBefore = function(block, task, err) {};
-
- _Class.prototype.blockTaskAfter = function(block, task, err) {};
-
- function _Class(opts) {
- var block, complete, err, fn, name, parentBlock;
-
- block = this;
- name = opts.name, fn = opts.fn, parentBlock = opts.parentBlock, complete = opts.complete;
- block.blockName = name;
- if (parentBlock != null) {
- block.parentBlock = parentBlock;
- }
- block.mode = 'sync';
- block.fn = fn;
- _Class.__super__.constructor.call(this, function(err) {
- block.blockAfter(block, err);
- return typeof complete === "function" ? complete(err) : void 0;
- });
- block.blockBefore(block);
- if (block.fn != null) {
- if (block.fn.length === 3) {
- block.total = Infinity;
- }
- try {
- block.fn(function(name, fn) {
- return block.block(name, fn);
- }, function(name, fn) {
- return block.task(name, fn);
- }, function(err) {
- return block.exit(err);
- });
- if (block.fn.length !== 3) {
- block.run();
- }
- } catch (_error) {
- err = _error;
- block.exit(err);
- }
- } else {
- block.total = Infinity;
- }
- this;
- }
-
- _Class.prototype.block = function(name, fn) {
- var block, pushBlock;
-
- block = this;
- pushBlock = function(fn) {
- if (block.total === Infinity) {
- return block.pushAndRun(fn);
- } else {
- return block.push(fn);
- }
- };
- pushBlock(function(complete) {
- var subBlock;
-
- return subBlock = block.createSubBlock({
- name: name,
- fn: fn,
- complete: complete
- });
- });
- return this;
- };
-
- _Class.prototype.createSubBlock = function(opts) {
- opts.parentBlock = this;
- return new balUtilFlow.Block(opts);
- };
-
- _Class.prototype.task = function(name, fn) {
- var block, pushTask;
-
- block = this;
- pushTask = function(fn) {
- if (block.total === Infinity) {
- return block.pushAndRun(fn);
- } else {
- return block.push(fn);
- }
- };
- pushTask(function(complete) {
- var preComplete;
-
- preComplete = function(err) {
- block.blockTaskAfter(block, name, err);
- return complete(err);
- };
- block.blockTaskBefore(block, name);
- return balUtilFlow.fireWithOptionalCallback(fn, [preComplete]);
- });
- return this;
- };
-
- return _Class;
-
- })(balUtilFlow.Group);
-
- balUtilFlow.Runner = (function() {
- _Class.prototype.runnerBlock = null;
-
- function _Class() {
- var _ref;
-
- if ((_ref = this.runnerBlock) == null) {
- this.runnerBlock = new balUtilFlow.Block();
- }
- }
-
- _Class.prototype.getRunnerBlock = function() {
- return this.runnerBlock;
- };
-
- _Class.prototype.block = function() {
- var args, _ref;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return (_ref = this.getRunnerBlock()).block.apply(_ref, args);
- };
-
- _Class.prototype.task = function() {
- var args, _ref;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return (_ref = this.getRunnerBlock()).task.apply(_ref, args);
- };
-
- return _Class;
-
- })();
-
- if (typeof module !== "undefined" && module !== null) {
- module.exports = balUtilFlow;
- } else {
- this.balUtilFlow = balUtilFlow;
- }
-
-}).call(this);
diff --git a/out/lib/html.js b/out/lib/html.js
deleted file mode 100644
index fd3aa81..0000000
--- a/out/lib/html.js
+++ /dev/null
@@ -1,99 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var balUtilFlow, balUtilHTML,
- __slice = [].slice;
-
- balUtilFlow = (typeof require === "function" ? require('./flow') : void 0) || this.balUtilFlow;
-
- balUtilHTML = {
- getAttribute: function(attributes, attribute) {
- var match, regex, value;
-
- regex = new RegExp("(" + attribute + ")\\s*=\\s*('[^']+'|\\\"[^\\\"]+\\\"|[^'\\\"\\s]\\S*)", 'ig');
- value = null;
- while (match = regex.exec(attributes)) {
- value = match[2].trim().replace(/(^['"]\s*|\s*['"]$)/g, '');
- }
- return value;
- },
- detectIndentation: function(source) {
- var indentation, result;
-
- result = /\n([ \t]*)\S/m.exec(source);
- indentation = (result != null ? result[1] : void 0) || '';
- return indentation;
- },
- removeIndentation: function(source) {
- var indentation, regex, regexString, result;
-
- indentation = balUtilHTML.detectIndentation(source);
- regexString = indentation.replace(/\t/g, '\\t');
- regex = new RegExp("^" + regexString, 'gm');
- result = source.replace(regex, '').trim();
- return result;
- },
- replaceElement: function() {
- var args, element, html, regex, removeIndentation, replace, result, _ref;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (args.length === 1) {
- _ref = args[0], html = _ref.html, element = _ref.element, removeIndentation = _ref.removeIndentation, replace = _ref.replace;
- } else {
- html = args[0], element = args[1], replace = args[2];
- }
- regex = new RegExp("<(" + element + "(?:\\:[-:_a-z0-9]+)?)(\\s+[^>]+)?>([\\s\\S]+?)<\\/\\1>", 'ig');
- result = html.replace(regex, function(outerHTML, element, attributes, innerHTML) {
- if (removeIndentation !== false) {
- innerHTML = balUtilHTML.removeIndentation(innerHTML);
- }
- return replace(outerHTML, element, attributes, innerHTML);
- });
- return result;
- },
- replaceElementAsync: function() {
- var args, element, html, next, removeIndentation, replace, result, tasks, _ref;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (args.length === 1) {
- _ref = args[0], html = _ref.html, element = _ref.element, removeIndentation = _ref.removeIndentation, replace = _ref.replace, next = _ref.next;
- } else {
- html = args[0], element = args[1], replace = args[2], next = args[3];
- }
- tasks = new balUtilFlow.Group(function(err) {
- if (err) {
- return next(err);
- }
- return next(null, result);
- });
- result = balUtilHTML.replaceElement({
- html: html,
- element: element,
- removeIndentation: removeIndentation,
- replace: function(outerHTML, element, attributes, innerHTML) {
- var random;
-
- random = Math.random();
- tasks.push(function(complete) {
- return replace(outerHTML, element, attributes, innerHTML, function(err, replaceElementResult) {
- if (err) {
- return complete(err);
- }
- result = result.replace(random, replaceElementResult);
- return complete();
- });
- });
- return random;
- }
- });
- tasks.sync();
- return this;
- }
- };
-
- if (typeof module !== "undefined" && module !== null) {
- module.exports = balUtilHTML;
- } else {
- this.balUtilHTML = balUtilHTML;
- }
-
-}).call(this);
diff --git a/out/lib/modules.js b/out/lib/modules.js
deleted file mode 100644
index 95bf737..0000000
--- a/out/lib/modules.js
+++ /dev/null
@@ -1,658 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var balUtilFlow, balUtilModules, balUtilPaths, balUtilTypes, isWindows, _ref, _ref1, _ref2, _ref3, _ref4,
- __slice = [].slice;
-
- balUtilModules = null;
-
- balUtilFlow = require('./flow');
-
- balUtilPaths = require('./paths');
-
- balUtilTypes = require('./types');
-
- isWindows = (typeof process !== "undefined" && process !== null ? (_ref = process.platform) != null ? _ref.indexOf('win') : void 0 : void 0) === 0;
-
- if ((_ref1 = global.numberOfOpenProcesses) == null) {
- global.numberOfOpenProcesses = 0;
- }
-
- if ((_ref2 = global.maxNumberOfOpenProcesses) == null) {
- global.maxNumberOfOpenProcesses = (_ref3 = process.env.NODE_MAX_OPEN_PROCESSES) != null ? _ref3 : 30;
- }
-
- if ((_ref4 = global.waitingToOpenProcessDelay) == null) {
- global.waitingToOpenProcessDelay = 100;
- }
-
- balUtilModules = {
- requireFresh: function(path) {
- var result;
-
- path = require('path').resolve(path);
- delete require.cache[path];
- result = require(path);
- delete require.cache[path];
- return result;
- },
- isWindows: function() {
- return isWindows;
- },
- getLocaleCode: function(lang) {
- var localeCode;
-
- if (lang == null) {
- lang = null;
- }
- if (lang == null) {
- lang = process.env.LANG || '';
- }
- localeCode = lang.replace(/\..+/, '').replace('-', '_').toLowerCase() || null;
- return localeCode;
- },
- getLanguageCode: function(localeCode) {
- var languageCode;
-
- if (localeCode == null) {
- localeCode = null;
- }
- localeCode = balUtilModules.getLocaleCode(localeCode) || '';
- languageCode = localeCode.replace(/^([a-z]+)[_-]([a-z]+)$/i, '$1').toLowerCase() || null;
- return languageCode;
- },
- getCountryCode: function(localeCode) {
- var countryCode;
-
- if (localeCode == null) {
- localeCode = null;
- }
- localeCode = balUtilModules.getLocaleCode(localeCode) || '';
- countryCode = localeCode.replace(/^([a-z]+)[_-]([a-z]+)$/i, '$2').toLowerCase() || null;
- return countryCode;
- },
- openProcess: function(next) {
- if (global.numberOfOpenProcesses < 0) {
- throw new Error("balUtilModules.openProcess: the numberOfOpenProcesses is [" + global.numberOfOpenProcesses + "] which should be impossible...");
- }
- if (global.numberOfOpenProcesses >= global.maxNumberOfOpenProcesses) {
- setTimeout(function() {
- return balUtilModules.openProcess(next);
- }, global.waitingToOpenProcessDelay);
- } else {
- ++global.numberOfOpenProcesses;
- next();
- }
- 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, _ref5;
-
- spawn = require('child_process').spawn;
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- pid = null;
- err = null;
- stdout = '';
- stderr = '';
- if (balUtilTypes.isString(command)) {
- command = command.split(' ');
- }
- if (balUtilTypes.isArray(command)) {
- pid = spawn(command[0], command.slice(1), opts);
- } else {
- pid = spawn(command.command, command.args || [], command.options || opts);
- }
- pid.stdout.on('data', function(data) {
- if (opts.output) {
- process.stdout.write(data);
- }
- return stdout += data.toString();
- });
- pid.stderr.on('data', function(data) {
- if (opts.output) {
- process.stderr.write(data);
- }
- return stderr += data.toString();
- });
- 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 this;
- },
- spawnMultiple: function(commands, opts, next) {
- var command, results, tasks, _i, _len, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- opts.tasksMode || (opts.tasksMode = 'serial');
- results = [];
- tasks = new balUtilFlow.Group(opts.tasksMode, function(err) {
- return next(err, results);
- });
- if (!balUtilTypes.isArray(commands)) {
- commands = [commands];
- }
- for (_i = 0, _len = commands.length; _i < _len; _i++) {
- command = commands[_i];
- tasks.push({
- command: command
- }, function(complete) {
- return balUtilModules.spawn(this.command, opts, function() {
- var args, err;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- err = args[0] || null;
- results.push(args);
- return complete(err);
- });
- });
- }
- tasks.run();
- return this;
- },
- exec: function(command, opts, next) {
- balUtilModules.openProcess(function() {
- var exec, _ref5;
-
- exec = require('child_process').exec;
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- if (opts.output) {
- opts.stdio = 'inherit';
- delete opts.output;
- }
- return exec(command, opts, function(err, stdout, stderr) {
- balUtilModules.closeProcess();
- return next(err, stdout, stderr);
- });
- });
- return this;
- },
- execMultiple: function(commands, opts, next) {
- var command, results, tasks, _i, _len, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- opts.tasksMode || (opts.tasksMode = 'serial');
- results = [];
- tasks = new balUtilFlow.Group(opts.tasksMode, function(err) {
- return next(err, results);
- });
- if (!balUtilTypes.isArray(commands)) {
- commands = [commands];
- }
- for (_i = 0, _len = commands.length; _i < _len; _i++) {
- command = commands[_i];
- tasks.push({
- command: command
- }, function(complete) {
- return balUtilModules.exec(this.command, opts, function() {
- var args, err;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- err = args[0] || null;
- results.push(args);
- return complete(err);
- });
- });
- }
- tasks.sync();
- return this;
- },
- determineExecPath: function(possibleExecPaths, next) {
- var execPath, pathUtil, possibleExecPath, tasks, _i, _len;
-
- pathUtil = require('path');
- execPath = null;
- tasks = new balUtilFlow.Group(function(err) {
- return next(err, execPath);
- });
- for (_i = 0, _len = possibleExecPaths.length; _i < _len; _i++) {
- possibleExecPath = possibleExecPaths[_i];
- if (!possibleExecPath) {
- continue;
- }
- tasks.push({
- possibleExecPath: possibleExecPath
- }, function(complete) {
- possibleExecPath = this.possibleExecPath;
- possibleExecPath = pathUtil.resolve(possibleExecPath);
- return balUtilPaths.exists(possibleExecPath, function(exists) {
- if (!exists) {
- return complete();
- }
- return balUtilModules.spawn([possibleExecPath, '--version'], {
- env: process.env
- }, function(err, stdout, stderr, code, signal) {
- if (err) {
- return complete();
- } else {
- execPath = possibleExecPath;
- return tasks.exit();
- }
- });
- });
- });
- }
- tasks.sync();
- return this;
- },
- getEnvironmentPaths: function() {
- var environmentPaths;
-
- if (balUtilModules.isWindows()) {
- environmentPaths = process.env.PATH.split(/;/g);
- } else {
- environmentPaths = process.env.PATH.split(/:/g);
- }
- return environmentPaths;
- },
- getStandardExecPaths: function(execName) {
- var index, possibleExecPaths, value, _i, _len;
-
- possibleExecPaths = [process.cwd()].concat(balUtilModules.getEnvironmentPaths());
- for (index = _i = 0, _len = possibleExecPaths.length; _i < _len; index = ++_i) {
- value = possibleExecPaths[index];
- possibleExecPaths[index] = value.replace(/\/$/, '');
- }
- if (execName) {
- possibleExecPaths = balUtilFlow.suffixArray("/" + execName, possibleExecPaths);
- }
- return possibleExecPaths;
- },
- getExecPath: function(execName, next) {
- var possibleExecPaths;
-
- if (isWindows && execName.indexOf('.') === -1) {
- possibleExecPaths = balUtilModules.getStandardExecPaths(execName + '.exe').concat(balUtilModules.getStandardExecPaths(execName));
- } else {
- possibleExecPaths = balUtilModules.getStandardExecPaths(execName);
- }
- balUtilModules.determineExecPath(possibleExecPaths, next);
- return this;
- },
- getHomePath: function(next) {
- var homePath;
-
- if (balUtilModules.cachedHomePath != null) {
- next(null, balUtilModules.cachedHomePath);
- return this;
- }
- homePath = process.env.USERPROFILE || process.env.HOME;
- homePath || (homePath = null);
- balUtilModules.cachedHomePath = homePath;
- next(null, homePath);
- return this;
- },
- getTmpPath: function(next) {
- var pathUtil, tmpDirName, tmpPath;
-
- if (balUtilModules.cachedTmpPath != null) {
- next(null, balUtilModules.cachedTmpPath);
- return this;
- }
- pathUtil = require('path');
- tmpDirName = isWindows ? 'temp' : 'tmp';
- tmpPath = process.env.TMPDIR || process.env.TMP || process.env.TEMP;
- if (!tmpPath) {
- balUtilModules.getHomePath(function(err, homePath) {
- if (err) {
- return next(err);
- }
- tmpPath = pathUtil.resolve(homePath, tmpDirName);
- if (!tmpPath) {
- return tmpPath = isWindows ? pathUtil.resolve(process.env.windir || 'C:\\Windows', tmpDirName) : '/tmp';
- }
- });
- }
- tmpPath || (tmpPath = null);
- balUtilModules.cachedTmpPath = tmpPath;
- next(null, tmpPath);
- return this;
- },
- getGitPath: function(next) {
- var execName, possibleExecPaths;
-
- if (balUtilModules.cachedGitPath != null) {
- next(null, balUtilModules.cachedGitPath);
- return this;
- }
- execName = isWindows ? 'git.exe' : 'git';
- possibleExecPaths = [process.env.GIT_PATH, process.env.GITPATH].concat(balUtilModules.getStandardExecPaths(execName)).concat(isWindows ? ["/Program Files (x64)/Git/bin/" + execName, "/Program Files (x86)/Git/bin/" + execName, "/Program Files/Git/bin/" + execName] : ["/usr/local/bin/" + execName, "/usr/bin/" + execName, "~/bin/" + execName]);
- balUtilModules.determineExecPath(possibleExecPaths, function(err, execPath) {
- balUtilModules.cachedGitPath = execPath;
- if (err) {
- return next(err);
- }
- if (!execPath) {
- return next(new Error('Could not locate git binary'));
- }
- return next(null, execPath);
- });
- return this;
- },
- getNodePath: function(next) {
- var execName, possibleExecPaths;
-
- if (balUtilModules.cachedNodePath != null) {
- next(null, balUtilModules.cachedNodePath);
- return this;
- }
- execName = isWindows ? 'node.exe' : 'node';
- possibleExecPaths = [process.env.NODE_PATH, process.env.NODEPATH, (/node(.exe)?$/.test(process.execPath) ? process.execPath : '')].concat(balUtilModules.getStandardExecPaths(execName)).concat(isWindows ? ["/Program Files (x64)/nodejs/" + execName, "/Program Files (x86)/nodejs/" + execName, "/Program Files/nodejs/" + execName] : ["/usr/local/bin/" + execName, "/usr/bin/" + execName, "~/bin/" + execName]);
- balUtilModules.determineExecPath(possibleExecPaths, function(err, execPath) {
- balUtilModules.cachedNodePath = execPath;
- if (err) {
- return next(err);
- }
- if (!execPath) {
- return next(new Error('Could not locate node binary'));
- }
- return next(null, execPath);
- });
- return this;
- },
- getNpmPath: function(next) {
- var execName, possibleExecPaths;
-
- if (balUtilModules.cachedNpmPath != null) {
- next(null, balUtilModules.cachedNpmPath);
- return this;
- }
- execName = isWindows ? 'npm.cmd' : 'npm';
- possibleExecPaths = [process.env.NPM_PATH, process.env.NPMPATH, (/node(.exe)?$/.test(process.execPath) ? process.execPath.replace(/node(.exe)?$/, execName) : '')].concat(balUtilModules.getStandardExecPaths(execName)).concat(isWindows ? ["/Program Files (x64)/nodejs/" + execName, "/Program Files (x86)/nodejs/" + execName, "/Program Files/nodejs/" + execName] : ["/usr/local/bin/" + execName, "/usr/bin/" + execName, "~/node_modules/.bin/" + execName]);
- balUtilModules.determineExecPath(possibleExecPaths, function(err, execPath) {
- balUtilModules.cachedNpmPath = execPath;
- if (err) {
- return next(err);
- }
- if (!execPath) {
- return next(new Error('Could not locate npm binary'));
- }
- return next(null, execPath);
- });
- return this;
- },
- gitCommand: function(command, opts, next) {
- var performSpawn, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- if (balUtilTypes.isString(command)) {
- command = command.split(' ');
- } else if (!balUtilTypes.isArray(command)) {
- return next(new Error('unknown command type'));
- }
- performSpawn = function() {
- command.unshift(opts.gitPath);
- return balUtilModules.spawn(command, opts, next);
- };
- if (opts.gitPath) {
- performSpawn();
- } else {
- balUtilModules.getGitPath(function(err, gitPath) {
- if (err) {
- return next(err);
- }
- opts.gitPath = gitPath;
- return performSpawn();
- });
- }
- return this;
- },
- gitCommands: function(commands, opts, next) {
- var command, results, tasks, _i, _len, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- results = [];
- tasks = new balUtilFlow.Group(function(err) {
- return next(err, results);
- });
- if (!balUtilTypes.isArray(commands)) {
- commands = [commands];
- }
- for (_i = 0, _len = commands.length; _i < _len; _i++) {
- command = commands[_i];
- tasks.push({
- command: command
- }, function(complete) {
- return balUtilModules.gitCommand(this.command, opts, function() {
- var args, err;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- err = args[0] || null;
- results.push(args);
- return complete(err);
- });
- });
- }
- tasks.sync();
- return this;
- },
- nodeCommand: function(command, opts, next) {
- var performSpawn, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- if (balUtilTypes.isString(command)) {
- command = command.split(' ');
- } else if (!balUtilTypes.isArray(command)) {
- return next(new Error('unknown command type'));
- }
- performSpawn = function() {
- command.unshift(opts.nodePath);
- return balUtilModules.spawn(command, opts, next);
- };
- if (opts.nodePath) {
- performSpawn();
- } else {
- balUtilModules.getNodePath(function(err, nodePath) {
- if (err) {
- return next(err);
- }
- opts.nodePath = nodePath;
- return performSpawn();
- });
- }
- return this;
- },
- nodeCommands: function(commands, opts, next) {
- var command, results, tasks, _i, _len, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- results = [];
- tasks = new balUtilFlow.Group(function(err) {
- return next(err, results);
- });
- if (!balUtilTypes.isArray(commands)) {
- commands = [commands];
- }
- for (_i = 0, _len = commands.length; _i < _len; _i++) {
- command = commands[_i];
- tasks.push({
- command: command
- }, function(complete) {
- return balUtilModules.nodeCommand(this.command, opts, function() {
- var args, err;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- err = args[0] || null;
- results.push(args);
- return complete(err);
- });
- });
- }
- tasks.sync();
- return this;
- },
- npmCommand: function(command, opts, next) {
- var performSpawn, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- if (balUtilTypes.isString(command)) {
- command = command.split(' ');
- } else if (!balUtilTypes.isArray(command)) {
- return next(new Error('unknown command type'));
- }
- performSpawn = function() {
- command.unshift(opts.npmPath);
- return balUtilModules.spawn(command, opts, next);
- };
- if (opts.npmPath) {
- performSpawn();
- } else {
- balUtilModules.getNpmPath(function(err, npmPath) {
- if (err) {
- return next(err);
- }
- opts.npmPath = npmPath;
- return performSpawn();
- });
- }
- return this;
- },
- npmCommands: function(commands, opts, next) {
- var command, results, tasks, _i, _len, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- results = [];
- tasks = new balUtilFlow.Group(function(err) {
- return next(err, results);
- });
- if (!balUtilTypes.isArray(commands)) {
- commands = [commands];
- }
- for (_i = 0, _len = commands.length; _i < _len; _i++) {
- command = commands[_i];
- tasks.push({
- command: command
- }, function(complete) {
- return balUtilModules.npmCommand(this.command, opts, function() {
- var args, err;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- err = args[0] || null;
- results.push(args);
- return complete(err);
- });
- });
- }
- tasks.sync();
- return this;
- },
- initGitRepo: function(opts, next) {
- var branch, commands, gitPath, logger, output, path, remote, url, _ref5;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- path = opts.path, remote = opts.remote, url = opts.url, branch = opts.branch, logger = opts.logger, output = opts.output, gitPath = opts.gitPath;
- remote || (remote = 'origin');
- branch || (branch = 'master');
- commands = [['init'], ['remote', 'add', remote, url], ['fetch', remote], ['pull', remote, branch], ['submodule', 'init'], ['submodule', 'update', '--recursive']];
- if (logger) {
- logger.log('debug', "Initializing git repo with url [" + url + "] on directory [" + path + "]");
- }
- balUtilModules.gitCommands(commands, {
- gitPath: gitPath,
- cwd: path,
- output: output
- }, function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (args[0] != null) {
- return next.apply(null, args);
- }
- if (logger) {
- logger.log('debug', "Initialized git repo with url [" + url + "] on directory [" + path + "]");
- }
- return next.apply(null, args);
- });
- return this;
- },
- initOrPullGitRepo: function(opts, next) {
- var branch, path, remote, _ref5,
- _this = this;
-
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- path = opts.path, remote = opts.remote, branch = opts.branch;
- remote || (remote = 'origin');
- branch || (branch = 'master');
- balUtilPaths.ensurePath(path, function(err, exists) {
- if (err) {
- return complete(err);
- }
- if (exists) {
- opts.cwd = path;
- return balUtilModules.gitCommand(['pull', remote, branch], opts, next);
- } else {
- return balUtilModules.initGitRepo(opts, next);
- }
- });
- return this;
- },
- initNodeModules: function(opts, next) {
- var force, logger, nodeModulesPath, packageJsonPath, partTwo, path, pathUtil, _ref5;
-
- pathUtil = require('path');
- _ref5 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref5[0], next = _ref5[1];
- path = opts.path, logger = opts.logger, force = opts.force;
- opts.cwd = path;
- packageJsonPath = pathUtil.join(path, 'package.json');
- nodeModulesPath = pathUtil.join(path, 'node_modules');
- partTwo = function() {
- return balUtilPaths.exists(packageJsonPath, function(exists) {
- var command;
-
- if (!exists) {
- return next();
- }
- command = ['install'];
- if (force) {
- command.push('--force');
- }
- if (logger) {
- logger.log('debug', "Initializing node modules\non: " + dirPath + "\nwith:", command);
- }
- return balUtilModules.npmCommand(command, opts, function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (args[0] != null) {
- return next.apply(null, args);
- }
- if (logger) {
- logger.log('debug', "Initialized node modules\non: " + dirPath + "\nwith:", command);
- }
- return next.apply(null, args);
- });
- });
- };
- if (force === false) {
- balUtilPaths.exists(nodeModulesPath, function(exists) {
- if (exists) {
- return next();
- }
- return partTwo();
- });
- } else {
- partTwo();
- }
- return this;
- }
- };
-
- module.exports = balUtilModules;
-
-}).call(this);
diff --git a/out/lib/paths.js b/out/lib/paths.js
deleted file mode 100644
index cd9d522..0000000
--- a/out/lib/paths.js
+++ /dev/null
@@ -1,888 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var balUtilFlow, balUtilPaths, balUtilTypes, fsUtil, pathUtil, _ref, _ref1, _ref2, _ref3, _ref4, _ref5,
- __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; },
- __slice = [].slice,
- __hasProp = {}.hasOwnProperty;
-
- fsUtil = require('fs');
-
- pathUtil = require('path');
-
- balUtilFlow = require('./flow');
-
- balUtilTypes = require('./types');
-
- if ((_ref = global.numberOfOpenFiles) == null) {
- global.numberOfOpenFiles = 0;
- }
-
- if ((_ref1 = global.maxNumberOfOpenFiles) == null) {
- global.maxNumberOfOpenFiles = (_ref2 = process.env.NODE_MAX_OPEN_FILES) != null ? _ref2 : 100;
- }
-
- if ((_ref3 = global.waitingToOpenFileDelay) == null) {
- global.waitingToOpenFileDelay = 100;
- }
-
- balUtilPaths = {
- ignoreCommonPatterns: (_ref4 = process.env.NODE_IGNORE_COMMON_PATTERNS) != null ? _ref4 : /^((~|\.\#).*|.*(\.swp)|\.(svn|git|hg|DS_Store)|node_modules|CVS|thumbs\.db|desktop\.ini)$/i,
- ignoreCustomPatterns: (_ref5 = process.env.NODE_IGNORE_CUSTOM_PATTERNS) != null ? _ref5 : null,
- textExtensions: ['c', 'coffee', 'coffeekup', 'cson', 'css', 'eco', 'haml', 'hbs', 'htaccess', 'htm', 'html', 'jade', 'js', 'json', 'less', 'md', 'php', 'phtml', 'py', 'rb', 'rtf', 'sass', 'scss', 'styl', 'stylus', 'text', 'txt', 'xml', 'yaml'].concat((process.env.TEXT_EXTENSIONS || '').split(/[\s,]+/)),
- binaryExtensions: ['dds', 'eot', 'gif', 'ico', 'jar', 'jpeg', 'jpg', 'pdf', 'png', 'swf', 'tga', 'ttf', 'zip'].concat((process.env.BINARY_EXTENSIONS || '').split(/[\s,]+/)),
- openFile: function(next) {
- if (global.numberOfOpenFiles < 0) {
- throw new Error("balUtilPaths.openFile: the numberOfOpenFiles is [" + global.numberOfOpenFiles + "] which should be impossible...");
- }
- if (global.numberOfOpenFiles >= global.maxNumberOfOpenFiles) {
- setTimeout(function() {
- return balUtilPaths.openFile(next);
- }, global.waitingToOpenFileDelay);
- } else {
- ++global.numberOfOpenFiles;
- next();
- }
- return this;
- },
- closeFile: function(next) {
- --global.numberOfOpenFiles;
- if (typeof next === "function") {
- next();
- }
- return this;
- },
- readFile: function(path, encoding, next) {
- if (next == null) {
- next = encoding;
- encoding = null;
- }
- balUtilPaths.openFile(function() {
- return fsUtil.readFile(path, encoding, function(err, data) {
- balUtilPaths.closeFile();
- return next(err, data);
- });
- });
- return this;
- },
- writeFile: function(path, data, encoding, next) {
- if (next == null) {
- next = encoding;
- encoding = null;
- }
- balUtilPaths.ensurePath(pathUtil.dirname(path), function(err) {
- if (err) {
- return next(err);
- }
- return balUtilPaths.openFile(function() {
- return fsUtil.writeFile(path, data, encoding, function(err) {
- balUtilPaths.closeFile();
- return next(err);
- });
- });
- });
- return this;
- },
- mkdir: function(path, mode, next) {
- if (next == null) {
- next = mode;
- mode = null;
- }
- balUtilPaths.openFile(function() {
- return fsUtil.mkdir(path, mode, function(err) {
- balUtilPaths.closeFile();
- return next(err);
- });
- });
- return this;
- },
- stat: function(path, next) {
- balUtilPaths.openFile(function() {
- return fsUtil.stat(path, function(err, stat) {
- balUtilPaths.closeFile();
- return next(err, stat);
- });
- });
- return this;
- },
- readdir: function(path, next) {
- balUtilPaths.openFile(function() {
- return fsUtil.readdir(path, function(err, files) {
- balUtilPaths.closeFile();
- return next(err, files);
- });
- });
- return this;
- },
- unlink: function(path, next) {
- balUtilPaths.openFile(function() {
- return fsUtil.unlink(path, function(err) {
- balUtilPaths.closeFile();
- return next(err);
- });
- });
- return this;
- },
- rmdir: function(path, next) {
- balUtilPaths.openFile(function() {
- return fsUtil.rmdir(path, function(err) {
- balUtilPaths.closeFile();
- return next(err);
- });
- });
- return this;
- },
- exists: function(path, next) {
- var exists;
-
- exists = fsUtil.exists || pathUtil.exists;
- balUtilPaths.openFile(function() {
- return exists(path, function(exists) {
- balUtilPaths.closeFile();
- return next(exists);
- });
- });
- return this;
- },
- existsSync: function(path) {
- var existsSync, result;
-
- existsSync = fsUtil.existsSync || pathUtil.existsSync;
- result = existsSync(path);
- return result;
- },
- isTextSync: function(filename, buffer) {
- var extension, isText, _i, _len;
-
- isText = null;
- if (filename) {
- filename = pathUtil.basename(filename).split('.');
- for (_i = 0, _len = filename.length; _i < _len; _i++) {
- extension = filename[_i];
- if (__indexOf.call(balUtilPaths.textExtensions, extension) >= 0) {
- isText = true;
- break;
- }
- if (__indexOf.call(balUtilPaths.binaryExtensions, extension) >= 0) {
- isText = false;
- break;
- }
- }
- }
- if (buffer && isText === null) {
- isText = balUtilPaths.getEncodingSync(buffer) === 'utf8';
- }
- return isText;
- },
- isText: function(filename, buffer, next) {
- var result;
-
- result = this.isTextSync(filename, buffer);
- if (result instanceof Error) {
- next(err);
- } else {
- next(null, result);
- }
- return this;
- },
- getEncodingSync: function(buffer, opts) {
- var binaryEncoding, charCode, chunkBegin, chunkEnd, chunkLength, contentChunkUTF8, encoding, i, textEncoding, _i, _ref6;
-
- textEncoding = 'utf8';
- binaryEncoding = 'binary';
- if (opts == null) {
- chunkLength = 24;
- encoding = balUtilPaths.getEncodingSync(buffer, {
- chunkLength: chunkLength,
- chunkBegin: chunkBegin
- });
- if (encoding === textEncoding) {
- chunkBegin = Math.max(0, Math.floor(buffer.length / 2) - chunkLength);
- encoding = balUtilPaths.getEncodingSync(buffer, {
- chunkLength: chunkLength,
- chunkBegin: chunkBegin
- });
- if (encoding === textEncoding) {
- chunkBegin = Math.max(0, buffer.length - chunkLength);
- encoding = balUtilPaths.getEncodingSync(buffer, {
- chunkLength: chunkLength,
- chunkBegin: chunkBegin
- });
- }
- }
- } else {
- chunkLength = opts.chunkLength, chunkBegin = opts.chunkBegin;
- if (chunkLength == null) {
- chunkLength = 24;
- }
- if (chunkBegin == null) {
- chunkBegin = 0;
- }
- chunkEnd = Math.min(buffer.length, chunkBegin + chunkLength);
- contentChunkUTF8 = buffer.toString(textEncoding, chunkBegin, chunkEnd);
- encoding = textEncoding;
- for (i = _i = 0, _ref6 = contentChunkUTF8.length; 0 <= _ref6 ? _i < _ref6 : _i > _ref6; i = 0 <= _ref6 ? ++_i : --_i) {
- charCode = contentChunkUTF8.charCodeAt(i);
- if (charCode === 65533 || charCode <= 8) {
- encoding = binaryEncoding;
- break;
- }
- }
- }
- return encoding;
- },
- getEncoding: function(buffer, opts, next) {
- var result;
-
- result = this.getEncodingSync(buffer, opts);
- if (result instanceof Error) {
- next(err);
- } else {
- next(null, result);
- }
- return this;
- },
- cp: function(src, dst, next) {
- balUtilPaths.readFile(src, 'binary', function(err, data) {
- if (err) {
- return next(err);
- }
- return balUtilPaths.writeFile(dst, data, 'binary', function(err) {
- return next(err);
- });
- });
- return this;
- },
- getParentPathSync: function(p) {
- var parentPath;
-
- parentPath = p.replace(/[\/\\][^\/\\]+$/, '');
- return parentPath;
- },
- ensurePath: function(path, next) {
- path = path.replace(/[\/\\]$/, '');
- balUtilPaths.exists(path, function(exists) {
- var parentPath;
-
- if (exists) {
- return next(null, true);
- }
- parentPath = balUtilPaths.getParentPathSync(path);
- return balUtilPaths.ensurePath(parentPath, function(err) {
- if (err) {
- return next(err, false);
- }
- return balUtilPaths.mkdir(path, '700', function(err) {
- return balUtilPaths.exists(path, function(exists) {
- if (!exists) {
- err = new Error("Failed to create the directory: " + path);
- return next(err, false);
- }
- return next(null, false);
- });
- });
- });
- });
- return this;
- },
- prefixPathSync: function(path, parentPath) {
- path = path.replace(/[\/\\]$/, '');
- if (/^([a-zA-Z]\:|\/)/.test(path) === false) {
- path = pathUtil.join(parentPath, path);
- }
- return path;
- },
- isDirectory: function(path, next) {
- if ((path != null ? path.isDirectory : void 0) != null) {
- return next(null, path.isDirectory(), path);
- } else {
- balUtilPaths.stat(path, function(err, stat) {
- if (err) {
- return next(err);
- }
- return next(null, stat.isDirectory(), stat);
- });
- }
- return this;
- },
- generateSlugSync: function(path) {
- var result;
-
- result = path.replace(/[^a-zA-Z0-9]/g, '-').replace(/^-/, '').replace(/-+/, '-');
- return result;
- },
- scanlist: function(path, next) {
- balUtilPaths.scandir({
- path: path,
- readFiles: true,
- ignoreHiddenFiles: true,
- next: function(err, list) {
- return next(err, list);
- }
- });
- return this;
- },
- scantree: function(path, next) {
- balUtilPaths.scandir({
- path: path,
- readFiles: true,
- ignoreHiddenFiles: true,
- next: function(err, list, tree) {
- return next(err, tree);
- }
- });
- return this;
- },
- testIgnorePatterns: function() {
- var args;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- return this.isIgnoredPath.apply(this, args);
- },
- isIgnoredPath: function(path, opts) {
- var basename, ignorePath, result, _i, _len, _ref10, _ref6, _ref7, _ref8, _ref9;
-
- if (opts == null) {
- opts = {};
- }
- result = false;
- basename = pathUtil.basename(path);
- if ((_ref6 = opts.ignorePaths) == null) {
- opts.ignorePaths = false;
- }
- if ((_ref7 = opts.ignoreHiddenFiles) == null) {
- opts.ignoreHiddenFiles = false;
- }
- if ((_ref8 = opts.ignoreCommonPatterns) == null) {
- opts.ignoreCommonPatterns = true;
- }
- if ((_ref9 = opts.ignoreCustomPatterns) == null) {
- opts.ignoreCustomPatterns = false;
- }
- if (opts.ignoreCommonPatterns === true) {
- opts.ignoreCommonPatterns = balUtilPaths.ignoreCommonPatterns;
- }
- if (opts.ignorePaths) {
- _ref10 = opts.ignorePaths;
- for (_i = 0, _len = _ref10.length; _i < _len; _i++) {
- ignorePath = _ref10[_i];
- if (path.indexOf(ignorePath) === 0) {
- result = true;
- break;
- }
- }
- }
- result = result || (opts.ignoreHiddenFiles && /^\./.test(basename)) || (opts.ignoreCommonPatterns && opts.ignoreCommonPatterns.test(basename)) || (opts.ignoreCustomPatterns && opts.ignoreCustomPatterns.test(basename)) || false;
- return result;
- },
- scandir: function() {
- var args, err, list, opts, tasks, tree, _ref10, _ref11, _ref12, _ref6, _ref7, _ref8, _ref9;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- list = {};
- tree = {};
- if (args.length === 1) {
- opts = args[0];
- } else if (args.length >= 4) {
- opts = {
- path: args[0],
- fileAction: args[1] || null,
- dirAction: args[2] || null,
- next: args[3] || null
- };
- } else {
- err = new Error('balUtilPaths.scandir: unsupported arguments');
- if (next) {
- return next(err);
- } else {
- throw err;
- }
- }
- if ((_ref6 = opts.recurse) == null) {
- opts.recurse = true;
- }
- if ((_ref7 = opts.readFiles) == null) {
- opts.readFiles = false;
- }
- if ((_ref8 = opts.ignorePaths) == null) {
- opts.ignorePaths = false;
- }
- if ((_ref9 = opts.ignoreHiddenFiles) == null) {
- opts.ignoreHiddenFiles = false;
- }
- if ((_ref10 = opts.ignoreCommonPatterns) == null) {
- opts.ignoreCommonPatterns = false;
- }
- if (opts.action != null) {
- if ((_ref11 = opts.fileAction) == null) {
- opts.fileAction = opts.action;
- }
- if ((_ref12 = opts.dirAction) == null) {
- opts.dirAction = opts.action;
- }
- }
- if (opts.parentPath && !opts.path) {
- opts.path = opts.parentPath;
- }
- if (!opts.path) {
- err = new Error('balUtilPaths.scandir: path is needed');
- if (next) {
- return next(err);
- } else {
- throw err;
- }
- }
- tasks = new balUtilFlow.Group(function(err) {
- return opts.next(err, list, tree);
- });
- balUtilPaths.readdir(opts.path, function(err, files) {
- if (tasks.exited) {
- return;
- } else if (err) {
- return tasks.exit(err);
- }
- tasks.total += files.length;
- if (!files.length) {
- return tasks.exit();
- } else {
- return files.forEach(function(file) {
- var fileFullPath, fileRelativePath, isIgnoredFile;
-
- fileFullPath = pathUtil.join(opts.path, file);
- fileRelativePath = opts.relativePath ? pathUtil.join(opts.relativePath, file) : file;
- isIgnoredFile = balUtilPaths.isIgnoredPath(fileFullPath, {
- ignorePaths: opts.ignorePaths,
- ignoreHiddenFiles: opts.ignoreHiddenFiles,
- ignoreCommonPatterns: opts.ignoreCommonPatterns,
- ignoreCustomPatterns: opts.ignoreCustomPatterns
- });
- if (isIgnoredFile) {
- return tasks.complete();
- }
- return balUtilPaths.isDirectory(fileFullPath, function(err, isDirectory, fileStat) {
- var complete;
-
- if (tasks.exited) {
-
- } else if (err) {
- return tasks.exit(err);
- } else if (isDirectory) {
- complete = function(err, skip, subtreeCallback) {
- if (err) {
- return tasks.exit(err);
- }
- if (tasks.exited) {
- return tasks.exit();
- }
- if (skip !== true) {
- list[fileRelativePath] = 'dir';
- tree[file] = {};
- if (!opts.recurse) {
- return tasks.complete();
- } else {
- return balUtilPaths.scandir({
- path: fileFullPath,
- relativePath: fileRelativePath,
- fileAction: opts.fileAction,
- dirAction: opts.dirAction,
- readFiles: opts.readFiles,
- ignorePaths: opts.ignorePaths,
- ignoreHiddenFiles: opts.ignoreHiddenFiles,
- ignoreCommonPatterns: opts.ignoreCommonPatterns,
- ignoreCustomPatterns: opts.ignoreCustomPatterns,
- recurse: opts.recurse,
- stat: opts.fileStat,
- next: function(err, _list, _tree) {
- var filePath, fileType;
-
- tree[file] = _tree;
- for (filePath in _list) {
- if (!__hasProp.call(_list, filePath)) continue;
- fileType = _list[filePath];
- list[filePath] = fileType;
- }
- if (tasks.exited) {
- return tasks.exit();
- } else if (err) {
- return tasks.exit(err);
- } else if (subtreeCallback) {
- return subtreeCallback(tasks.completer());
- } else {
- return tasks.complete();
- }
- }
- });
- }
- } else {
- return tasks.complete();
- }
- };
- if (opts.dirAction) {
- return opts.dirAction(fileFullPath, fileRelativePath, complete, fileStat);
- } else if (opts.dirAction === false) {
- return complete(err, true);
- } else {
- return complete(err, false);
- }
- } else {
- complete = function(err, skip) {
- if (err) {
- return tasks.exit(err);
- }
- if (tasks.exited) {
- return tasks.exit();
- }
- if (skip) {
- return tasks.complete();
- } else {
- if (opts.readFiles) {
- return balUtilPaths.readFile(fileFullPath, function(err, data) {
- var dataString;
-
- if (err) {
- return tasks.exit(err);
- }
- dataString = data.toString();
- list[fileRelativePath] = dataString;
- tree[file] = dataString;
- return tasks.complete();
- });
- } else {
- list[fileRelativePath] = 'file';
- tree[file] = true;
- return tasks.complete();
- }
- }
- };
- if (opts.fileAction) {
- return opts.fileAction(fileFullPath, fileRelativePath, complete, fileStat);
- } else if (opts.fileAction === false) {
- return complete(err, true);
- } else {
- return complete(err, false);
- }
- }
- });
- });
- }
- });
- return this;
- },
- cpdir: function() {
- var args, err, next, opt, opts, outPath, scandirOpts, srcPath, _i, _len, _ref6;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- opts = {};
- if (args.length === 1) {
- opts = args[0];
- } else if (args.length >= 3) {
- srcPath = args[0], outPath = args[1], next = args[2];
- opts = {
- srcPath: srcPath,
- outPath: outPath,
- next: next
- };
- } else {
- err = new Error('balUtilPaths.cpdir: unknown arguments');
- if (next) {
- return next(err);
- } else {
- throw err;
- }
- }
- scandirOpts = {
- path: opts.srcPath,
- fileAction: function(fileSrcPath, fileRelativePath, next) {
- var fileOutPath;
-
- fileOutPath = pathUtil.join(opts.outPath, fileRelativePath);
- return balUtilPaths.ensurePath(pathUtil.dirname(fileOutPath), function(err) {
- if (err) {
- return next(err);
- }
- return balUtilPaths.cp(fileSrcPath, fileOutPath, function(err) {
- return next(err);
- });
- });
- },
- next: opts.next
- };
- _ref6 = ['ignorePaths', 'ignoreHiddenFiles', 'ignoreCommonPatterns', 'ignoreCustomPatterns'];
- for (_i = 0, _len = _ref6.length; _i < _len; _i++) {
- opt = _ref6[_i];
- scandirOpts[opt] = opts[opt];
- }
- balUtilPaths.scandir(scandirOpts);
- return this;
- },
- rpdir: function() {
- var args, err, next, opt, opts, outPath, scandirOpts, srcPath, _i, _len, _ref6;
-
- args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- opts = {};
- if (args.length === 1) {
- opts = args[0];
- } else if (args.length >= 3) {
- srcPath = args[0], outPath = args[1], next = args[2];
- opts = {
- srcPath: srcPath,
- outPath: outPath,
- next: next
- };
- } else {
- err = new Error('balUtilPaths.cpdir: unknown arguments');
- if (next) {
- return next(err);
- } else {
- throw err;
- }
- }
- scandirOpts = {
- path: opts.srcPath,
- fileAction: function(fileSrcPath, fileRelativePath, next) {
- var fileOutPath;
-
- fileOutPath = pathUtil.join(opts.outPath, fileRelativePath);
- return balUtilPaths.ensurePath(pathUtil.dirname(fileOutPath), function(err) {
- if (err) {
- return next(err);
- }
- return balUtilPaths.isPathOlderThan(fileOutPath, fileSrcPath, function(err, older) {
- if (older === true || older === null) {
- return balUtilPaths.cp(fileSrcPath, fileOutPath, function(err) {
- return next(err);
- });
- } else {
- return next();
- }
- });
- });
- },
- next: opts.next
- };
- _ref6 = ['ignorePaths', 'ignoreHiddenFiles', 'ignoreCommonPatterns', 'ignoreCustomPatterns'];
- for (_i = 0, _len = _ref6.length; _i < _len; _i++) {
- opt = _ref6[_i];
- scandirOpts[opt] = opts[opt];
- }
- balUtilPaths.scandir(scandirOpts);
- return this;
- },
- rmdirDeep: function(parentPath, next) {
- balUtilPaths.exists(parentPath, function(exists) {
- if (!exists) {
- return next();
- }
- return balUtilPaths.scandir(parentPath, function(fileFullPath, fileRelativePath, next) {
- return balUtilPaths.unlink(fileFullPath, function(err) {
- return next(err);
- });
- }, function(fileFullPath, fileRelativePath, next) {
- return next(null, false, function(next) {
- return balUtilPaths.rmdirDeep(fileFullPath, function(err) {
- return next(err);
- });
- });
- }, function(err, list, tree) {
- if (err) {
- return next(err, list, tree);
- }
- return balUtilPaths.rmdir(parentPath, function(err) {
- return next(err, list, tree);
- });
- });
- });
- return this;
- },
- writetree: function(dstPath, tree, next) {
- var tasks;
-
- tasks = new balUtilFlow.Group(function(err) {
- return next(err);
- });
- balUtilPaths.ensurePath(dstPath, function(err) {
- var fileFullPath, fileRelativePath, value;
-
- if (err) {
- return tasks.exit(err);
- }
- for (fileRelativePath in tree) {
- if (!__hasProp.call(tree, fileRelativePath)) continue;
- value = tree[fileRelativePath];
- ++tasks.total;
- fileFullPath = pathUtil.join(dstPath, fileRelativePath.replace(/^\/+/, ''));
- if (balUtilTypes.isObject(value)) {
- balUtilPaths.writetree(fileFullPath, value, tasks.completer());
- } else {
- balUtilPaths.writeFile(fileFullPath, value, function(err) {
- return tasks.complete(err);
- });
- }
- }
- if (tasks.total === 0) {
- tasks.exit();
- }
- });
- return this;
- },
- readPath: function(filePath, opts, next) {
- var data, err, http, req, requestOpts, tasks, zlib, _ref10, _ref11, _ref6, _ref7, _ref8, _ref9;
-
- _ref6 = balUtilFlow.extractOptsAndCallback(opts, next), opts = _ref6[0], next = _ref6[1];
- if (/^http/.test(filePath)) {
- data = '';
- tasks = new balUtilFlow.Group(function(err) {
- if (err) {
- return next(err);
- }
- return next(null, data);
- });
- requestOpts = require('url').parse(filePath);
- if ((_ref7 = requestOpts.path) == null) {
- requestOpts.path = requestOpts.pathname;
- }
- if ((_ref8 = requestOpts.method) == null) {
- requestOpts.method = 'GET';
- }
- if ((_ref9 = requestOpts.headers) == null) {
- requestOpts.headers = {};
- }
- http = requestOpts.protocol === 'https:' ? require('https') : require('http');
- zlib = null;
- try {
- zlib = require('zlib');
- } catch (_error) {
- err = _error;
- }
- req = http.request(requestOpts, function(res) {
- res.on('data', function(chunk) {
- return tasks.push(function(complete) {
- if (res.headers['content-encoding'] === 'gzip' && Buffer.isBuffer(chunk)) {
- if (zlib === null) {
- err = new Error('Gzip encoding not supported on this environment');
- return complete(err);
- }
- return zlib.unzip(chunk, function(err, chunk) {
- if (err) {
- return complete(err);
- }
- data += chunk;
- return complete();
- });
- } else {
- data += chunk;
- return complete();
- }
- });
- });
- return res.on('end', function() {
- var locationHeader, _ref10;
-
- locationHeader = ((_ref10 = res.headers) != null ? _ref10.location : void 0) || null;
- if (locationHeader && locationHeader !== requestOpts.href) {
- return balUtilPaths.readPath(locationHeader, function(err, _data) {
- if (err) {
- return tasks.exit(err);
- }
- data = _data;
- return tasks.exit();
- });
- } else {
- return tasks.run('serial');
- }
- });
- });
- if ((_ref10 = req.setTimeout) == null) {
- req.setTimeout = function(delay) {
- return setTimeout((function() {
- req.abort();
- return tasks.exit(new Error('Request timed out'));
- }), delay);
- };
- }
- req.setTimeout((_ref11 = opts.timeout) != null ? _ref11 : 10 * 1000);
- req.on('error', function(err) {
- return tasks.exit(err);
- }).on('timeout', function() {
- return req.abort();
- });
- req.end();
- } else {
- balUtilPaths.readFile(filePath, function(err, data) {
- if (err) {
- return next(err);
- }
- return next(null, data);
- });
- }
- return this;
- },
- empty: function(filePath, next) {
- balUtilPaths.exists(filePath, function(exists) {
- if (!exists) {
- return next(null, true);
- }
- return balUtilPaths.stat(filePath, function(err, stat) {
- if (err) {
- return next(err);
- }
- return next(null, stat.size === 0);
- });
- });
- return this;
- },
- isPathOlderThan: function(aPath, bInput, next) {
- var bMtime, bPath, mode;
-
- bMtime = null;
- if (balUtilTypes.isNumber(bInput)) {
- mode = 'time';
- bMtime = new Date(new Date() - bInput);
- } else {
- mode = 'path';
- bPath = bInput;
- }
- balUtilPaths.empty(aPath, function(err, empty) {
- if (empty || err) {
- return next(err, null);
- }
- return balUtilPaths.stat(aPath, function(err, aStat) {
- var compare;
-
- if (err) {
- return next(err);
- }
- compare = function() {
- var older;
-
- if (aStat.mtime < bMtime) {
- older = true;
- } else {
- older = false;
- }
- return next(null, older);
- };
- if (mode === 'path') {
- return balUtilPaths.empty(bPath, function(err, empty) {
- if (empty || err) {
- return next(err, null);
- }
- return balUtilPaths.stat(bPath, function(err, bStat) {
- if (err) {
- return next(err);
- }
- bMtime = bStat.mtime;
- return compare();
- });
- });
- } else {
- return compare();
- }
- });
- });
- return this;
- }
- };
-
- module.exports = balUtilPaths;
-
-}).call(this);
diff --git a/out/lib/types.js b/out/lib/types.js
deleted file mode 100644
index e88142d..0000000
--- a/out/lib/types.js
+++ /dev/null
@@ -1,99 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-/*
-NOTES:
-Instanceof is often broken and doesn't return the right value
-For instance it does not work in node virtual machines
-*/
-
-
-(function() {
- var balUtilTypes,
- __hasProp = {}.hasOwnProperty;
-
- balUtilTypes = {
- toString: function(value) {
- return Object.prototype.toString.call(value);
- },
- getType: function(value) {
- var result, type, _i, _len, _ref;
-
- result = 'object';
- _ref = ['Array', 'RegExp', 'Date', 'Function', 'Boolean', 'Number', 'Error', 'String', 'Null', 'Undefined'];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- type = _ref[_i];
- if (balUtilTypes['is' + type](value)) {
- result = type.toLowerCase();
- break;
- }
- }
- return result;
- },
- isPlainObject: function(value) {
- return balUtilTypes.isObject(value) && value.__proto__ === Object.prototype;
- },
- isObject: function(value) {
- return value && typeof value === 'object';
- },
- isError: function(value) {
- return value instanceof Error;
- },
- isDate: function(value) {
- return balUtilTypes.toString(value) === '[object Date]';
- },
- isArguments: function(value) {
- return balUtilTypes.toString(value) === '[object Arguments]';
- },
- isFunction: function(value) {
- return balUtilTypes.toString(value) === '[object Function]';
- },
- isRegExp: function(value) {
- return balUtilTypes.toString(value) === '[object RegExp]';
- },
- isArray: function(value) {
- if (Array.isArray != null) {
- return Array.isArray(value);
- } else {
- return balUtilTypes.toString(value) === '[object Array]';
- }
- },
- isNumber: function(value) {
- return typeof value === 'number' || balUtilTypes.toString(value) === '[object Number]';
- },
- isString: function(value) {
- return typeof value === 'string' || balUtilTypes.toString(value) === '[object String]';
- },
- isBoolean: function(value) {
- return value === true || value === false || balUtilTypes.toString(value) === '[object Boolean]';
- },
- isNull: function(value) {
- return value === null;
- },
- isUndefined: function(value) {
- return typeof value === 'undefined';
- },
- isEmpty: function(value) {
- return value != null;
- },
- isEmptyObject: function(value) {
- var empty, key;
-
- empty = true;
- if (value != null) {
- for (key in value) {
- if (!__hasProp.call(value, key)) continue;
- value = value[key];
- empty = false;
- break;
- }
- }
- return empty;
- }
- };
-
- if (typeof module !== "undefined" && module !== null) {
- module.exports = balUtilTypes;
- } else {
- this.balUtilTypes = balUtilTypes;
- }
-
-}).call(this);
diff --git a/out/test/compare.test.js b/out/test/compare.test.js
deleted file mode 100644
index 2541823..0000000
--- a/out/test/compare.test.js
+++ /dev/null
@@ -1,70 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var assert, balUtil, joe;
-
- assert = require('assert');
-
- joe = require('joe');
-
- balUtil = require(__dirname + '/../lib/balutil');
-
- joe.describe('versionCompare', function(describe, it) {
- var operator, resultActual, resultExpected, test, testVersion, v1, v2, versionCompareTestData, _i, _len, _results;
-
- versionCompareTestData = [['1.1.0', '<', '1.2.0', true], ['1.2.0', '>', '1.1.0', true], ['1.2.0', '==', '1.2.0', true], ['1.2.0', '<=', '1.2.0', true], ['1.2.0', '>=', '1.2.0', true], ['1.2.0', '<', '1.2.1', true], ['1.2.0', '<', '1.3.0', true], ['1.1.0', '>=', '1.2.0', false], ['1.2.0', '<=', '1.1.0', false], ['1.2.0', '<>', '1.2.0', false], ['1.2.0', '>', '1.2.0', false], ['1.2.0', '<', '1.2.0', false], ['1.2.0', '>=', '1.2.1', false], ['1.2.0', '>=', '1.3.0', false]];
- testVersion = function(v1, operator, v2, resultExpected, resultActual) {
- return it("should detect " + v1 + " " + operator + " " + v2 + " is " + resultExpected, function() {
- return assert.equal(resultActual, resultExpected);
- });
- };
- _results = [];
- for (_i = 0, _len = versionCompareTestData.length; _i < _len; _i++) {
- test = versionCompareTestData[_i];
- v1 = test[0];
- operator = test[1];
- v2 = test[2];
- resultExpected = test[3];
- resultActual = balUtil.versionCompare(v1, operator, v2);
- _results.push(testVersion(v1, operator, v2, resultExpected, resultActual));
- }
- return _results;
- });
-
- joe.describe('packageCompare', function(describe, it) {
- var localPackagePath, remotePackagePath, testVersion;
-
- if (process.version.indexOf('v0.4') === 0) {
- return it('test skipped for node v0.4', function() {});
- }
- localPackagePath = __dirname + '/../../package.json';
- remotePackagePath = 'https://raw.github.com/balupton/bal-util/master/package.json';
- testVersion = function(v1, operator, v2) {
- var resultActual;
-
- resultActual = balUtil.versionCompare(v1, operator, v2);
- return assert.equal(resultActual, true);
- };
- return it('should run as expected', function(done) {
- return balUtil.packageCompare({
- local: localPackagePath,
- remote: remotePackagePath,
- newVersionCallback: function(details) {
- testVersion(details.local.version, '<', details.remote.version);
- return done();
- },
- sameVersionCallback: function(details) {
- testVersion(details.local.version, '==', details.remote.version);
- return done();
- },
- oldVersionCallback: function(details) {
- testVersion(details.local.version, '>', details.remote.version);
- return done();
- },
- errorCallback: function(err, data) {
- return done(err);
- }
- });
- });
- });
-
-}).call(this);
diff --git a/out/test/events.test.js b/out/test/events.test.js
deleted file mode 100644
index 0ebde3e..0000000
--- a/out/test/events.test.js
+++ /dev/null
@@ -1,308 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var EventEmitterEnhanced, EventSystem, Person, assert, debug, expect, joe, _ref, _ref1, _ref2,
- __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
-
- _ref = require('chai'), expect = _ref.expect, assert = _ref.assert;
-
- joe = require('joe');
-
- _ref1 = require(__dirname + '/../lib/balutil'), EventEmitterEnhanced = _ref1.EventEmitterEnhanced, EventSystem = _ref1.EventSystem;
-
- debug = false;
-
- joe.describe('EventEmitterEnhanced', function(describe, it) {
- var eventEmitter;
-
- eventEmitter = null;
- it('should construct', function() {
- return eventEmitter = new EventEmitterEnhanced();
- });
- it('should work in serial', function(done) {
- var first, second;
-
- first = second = 0;
- eventEmitter.on('serial', function(opts, next) {
- first++;
- return setTimeout(function() {
- expect(second).to.eql(0);
- first++;
- return next();
- }, 500);
- });
- eventEmitter.on('serial', function() {
- expect(first).to.eql(2);
- return second += 2;
- });
- expect(eventEmitter.listeners('serial').length).to.eql(2);
- return eventEmitter.emitSerial('serial', null, function(err) {
- expect(first).to.eql(2);
- expect(second).to.eql(2);
- return done();
- });
- });
- it('should work in parallel', function(done) {
- var first, second;
-
- first = second = 0;
- eventEmitter.on('parallel', function(opts, next) {
- first++;
- return setTimeout(function() {
- expect(second).to.eql(2);
- first++;
- return next();
- }, 500);
- });
- eventEmitter.on('parallel', function() {
- expect(first).to.eql(1);
- return second += 2;
- });
- expect(eventEmitter.listeners('parallel').length).to.eql(2);
- return eventEmitter.emitParallel('parallel', null, function(err) {
- expect(first).to.eql(2);
- expect(second).to.eql(2);
- return done();
- });
- });
- return it('should work with once', function(done) {
- var first, second;
-
- first = second = 0;
- eventEmitter.once('once', function(opts, next) {
- first++;
- return setTimeout(function() {
- expect(second).to.eql(2);
- first++;
- return next();
- }, 500);
- });
- eventEmitter.once('once', function() {
- expect(first).to.eql(1);
- return second += 2;
- });
- expect(eventEmitter.listeners('once').length).to.eql(2);
- return eventEmitter.emitParallel('once', null, function(err) {
- expect(first).to.eql(2);
- expect(second).to.eql(2);
- expect(eventEmitter.listeners('once').length).to.eql(0);
- return done();
- });
- });
- });
-
- Person = (function(_super) {
- __extends(Person, _super);
-
- function Person() {
- _ref2 = Person.__super__.constructor.apply(this, arguments);
- return _ref2;
- }
-
- /*
- A person can eat while they drink, but they can't drink while they eat
- This has come from the fact that if you have food in your mouth, you can still drink things
- Whereas if you have drink in your mouth, then put food in your mouth, the drink goes everywhere
- */
-
-
- Person.prototype.eat = function(something, next) {
- var _this = this;
-
- if (debug) {
- console.log("" + something + ": started food");
- }
- if (debug) {
- console.log("" + something + ": start eating");
- }
- return this.start('eating', function(err) {
- if (debug) {
- console.log("" + something + ": eating");
- }
- if (err) {
- return typeof next === "function" ? next(err) : void 0;
- }
- return setTimeout(function() {
- if (debug) {
- console.log("" + something + ": swallowed food");
- }
- if (typeof next === "function") {
- next(null, something);
- }
- if (debug) {
- console.log("" + something + ": start finish");
- }
- return _this.finished('eating', function(err) {
- if (debug) {
- console.log("" + something + ": finished food");
- }
- if (err) {
- return typeof next === "function" ? next(err) : void 0;
- }
- });
- }, 2 * 1000);
- });
- };
-
- Person.prototype.drink = function(something, next) {
- var _this = this;
-
- if (debug) {
- console.log("" + something + ": started drink");
- }
- if (debug) {
- console.log("" + something + ": blocking eating");
- }
- return this.block('eating', function(err) {
- if (debug) {
- console.log("" + something + ": blocked eating");
- }
- if (err) {
- return typeof next === "function" ? next(err) : void 0;
- }
- if (debug) {
- console.log("" + something + ": start drinking");
- }
- return _this.start('drinking', function(err) {
- if (debug) {
- console.log("" + something + ": drinking");
- }
- if (err) {
- return typeof next === "function" ? next(err) : void 0;
- }
- return setTimeout(function() {
- if (debug) {
- console.log("" + something + ": swallowed drink");
- }
- if (typeof next === "function") {
- next(null, something);
- }
- if (debug) {
- console.log("" + something + ": start finish");
- }
- return _this.finished('drinking', function(err) {
- if (debug) {
- console.log("" + something + ": finished drink");
- }
- if (err) {
- return done(err);
- }
- if (debug) {
- console.log("" + something + ": unblocking eating");
- }
- return _this.unblock('eating', function(err) {
- if (debug) {
- console.log("" + something + ": unblocked eating");
- }
- if (err) {
- return done(err);
- }
- });
- });
- }, 1 * 1000);
- });
- });
- };
-
- return Person;
-
- })(EventSystem);
-
- joe.describe('EventSystem', function(describe, it) {
- return it('should work as expected', function(done) {
- var ateAFood, drankADrink, drink, drinking, drinks, drinksDrunk, eating, food, foods, foodsAte, myPerson, myPersonTriedToDrinkThenEat, _i, _j, _len, _len1;
-
- foods = ['apple', 'orange', 'grape'];
- drinks = ['coke', 'fanta', 'water'];
- myPerson = new Person();
- foodsAte = [];
- drinksDrunk = [];
- myPersonTriedToDrinkThenEat = false;
- eating = false;
- drinking = false;
- myPerson.on('eating:locked', function() {
- if (debug) {
- return console.log('eating:locked');
- }
- });
- myPerson.on('eating:unlocked', function() {
- if (debug) {
- return console.log('eating:unlocked');
- }
- });
- myPerson.on('eating:started', function() {
- if (debug) {
- console.log('eating:started');
- }
- if (drinking === true) {
- if (debug) {
- console.log('myPerson just tried to eat then drink');
- }
- myPersonTriedToDrinkThenEat = true;
- }
- return eating = true;
- });
- myPerson.on('eating:finished', function() {
- if (debug) {
- console.log('eating:finished');
- }
- return eating = false;
- });
- myPerson.on('drinking:locked', function() {
- if (debug) {
- return console.log('drinking:locked');
- }
- });
- myPerson.on('drinking:unlocked', function() {
- if (debug) {
- return console.log('drinking:unlocked');
- }
- });
- myPerson.on('drinking:started', function() {
- if (debug) {
- console.log('drinking:started');
- }
- return drinking = true;
- });
- myPerson.on('drinking:finished', function() {
- if (debug) {
- console.log('drinking:finished');
- }
- return drinking = false;
- });
- ateAFood = function(err, something) {
- if (err) {
- return done(err);
- }
- foodsAte.push(something);
- if (debug) {
- return console.log("completely finished eating " + something + " - " + foodsAte.length + "/" + foods.length);
- }
- };
- drankADrink = function(err, something) {
- if (err) {
- return done(err);
- }
- drinksDrunk.push(something);
- if (debug) {
- return console.log("completely finished drinking " + something + " - " + drinksDrunk.length + "/" + drinks.length);
- }
- };
- for (_i = 0, _len = foods.length; _i < _len; _i++) {
- food = foods[_i];
- myPerson.eat(food, ateAFood);
- }
- for (_j = 0, _len1 = drinks.length; _j < _len1; _j++) {
- drink = drinks[_j];
- myPerson.drink(drink, drankADrink);
- }
- return setTimeout(function() {
- assert.equal(foods.length, foodsAte.length, 'myPerson ate all his foods');
- assert.equal(drinks.length, drinksDrunk.length, 'myPerson ate all his drinks');
- assert.equal(false, myPersonTriedToDrinkThenEat, 'myPerson tried to drink then eat, when he shouldn\'t have');
- return done();
- }, 14000);
- });
- });
-
-}).call(this);
diff --git a/out/test/everything.test.js b/out/test/everything.test.js
deleted file mode 100644
index 805d98b..0000000
--- a/out/test/everything.test.js
+++ /dev/null
@@ -1,17 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- require(__dirname + '/types.test');
-
- require(__dirname + '/events.test');
-
- require(__dirname + '/flow.test');
-
- require(__dirname + '/html.test');
-
- require(__dirname + '/modules.test');
-
- require(__dirname + '/paths.test');
-
- require(__dirname + '/compare.test');
-
-}).call(this);
diff --git a/out/test/flow.test.js b/out/test/flow.test.js
deleted file mode 100644
index 3320dc9..0000000
--- a/out/test/flow.test.js
+++ /dev/null
@@ -1,664 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var assert, balUtil, joe, wait;
-
- assert = (typeof require === "function" ? require('assert') : void 0) || this.assert;
-
- joe = (typeof require === "function" ? require('joe') : void 0) || this.joe;
-
- balUtil = (typeof require === "function" ? require(__dirname + '/../lib/balutil') : void 0) || this.balUtil;
-
- wait = function(delay, fn) {
- return setTimeout(fn, delay);
- };
-
- joe.describe('misc', function(describe, it) {
- it('should suffix arrays', function(done) {
- var actual, expected;
-
- expected = ['ba', 'ca', 'da', 'ea'];
- actual = balUtil.suffixArray('a', 'b', ['c', 'd'], 'e');
- assert.deepEqual(expected, actual, 'actual was as expected');
- return done();
- });
- it('should detect arrays', function(done) {
- var arr, obj, str;
-
- arr = [];
- obj = {};
- str = '';
- assert.equal(true, balUtil.isArray(arr), 'array vs array comparison');
- assert.equal(false, balUtil.isArray(obj), 'object vs array comparison');
- assert.equal(false, balUtil.isArray(str), 'string vs array comparison');
- return done();
- });
- it('should cycle arrays', function(done) {
- var arr, out;
-
- arr = ['a', 'b', 'c'];
- out = [];
- balUtil.each(arr, function(value, key) {
- return out[key] = value;
- });
- assert.deepEqual(arr, out, 'cycling an array produced the expected results');
- return done();
- });
- it('should cycle objects', function(done) {
- var obj, out;
-
- obj = {
- 'a': 1,
- 'b': 2,
- 'c': 3
- };
- out = {};
- balUtil.each(obj, function(value, key) {
- return out[key] = value;
- });
- assert.deepEqual(obj, out, 'cycling an object produced the expected results');
- return done();
- });
- it('should shallow extend correctly', function(done) {
- var out, src;
-
- src = {
- a: {
- b: 2
- }
- };
- out = balUtil.shallowExtendPlainObjects({}, src);
- out.a.b = 3;
- assert.deepEqual({
- a: {
- b: 3
- }
- }, out, 'out object was as expected');
- assert.deepEqual({
- a: {
- b: 3
- }
- }, src, 'src object was modified');
- return done();
- });
- it('should safe shallow extend correctly', function(done) {
- var actual, expected;
-
- expected = {
- a: 2
- };
- actual = balUtil.safeShallowExtendPlainObjects({
- a: 1
- }, {
- a: 2
- }, {
- a: null
- });
- assert.deepEqual(actual, expected, 'out object was as expected');
- return done();
- });
- it('should deep extend correctly', function(done) {
- var out, src;
-
- src = {
- a: {
- b: 2
- }
- };
- out = balUtil.deepExtendPlainObjects({}, src);
- out.a.b = 3;
- assert.deepEqual({
- a: {
- b: 3
- }
- }, out, 'out object was as expected');
- assert.deepEqual({
- a: {
- b: 2
- }
- }, src, 'src object was not modified');
- return done();
- });
- it('should safe deep extend correctly', function(done) {
- var actual, expected;
-
- expected = {
- a: {
- b: 2
- }
- };
- actual = balUtil.safeDeepExtendPlainObjects({
- a: {
- b: 2
- }
- }, {
- a: {
- b: 2
- }
- }, {
- a: {
- b: null
- }
- });
- assert.deepEqual(actual, expected, 'out object was as expected');
- return done();
- });
- it('should dereference correctly', function(done) {
- var out, src;
-
- src = {
- a: {
- b: 2
- }
- };
- out = balUtil.dereference(src);
- out.a.b = 3;
- assert.deepEqual({
- a: {
- b: 3
- }
- }, out, 'out object was as expected');
- assert.deepEqual({
- a: {
- b: 2
- }
- }, src, 'src object was not modified');
- return done();
- });
- it('should getdeep correctly', function(done) {
- var actual, expected, src;
-
- src = {
- a: {
- b: {
- attributes: {
- c: 1
- }
- }
- }
- };
- expected = 1;
- actual = balUtil.getDeep(src, 'a.b.c');
- assert.equal(expected, actual, 'out value was as expected');
- actual = balUtil.getDeep(src, 'a.b.unknown');
- assert.ok(typeof actual === 'undefined', 'undefined value was as expected');
- return done();
- });
- return it('should setdeep correctly', function(done) {
- var expected, src;
-
- src = {
- a: {
- unknown: 'asd',
- b: {
- attributes: {
- c: 1
- }
- }
- }
- };
- expected = {
- a: {
- b: {
- attributes: {
- c: 2
- }
- }
- }
- };
- balUtil.setDeep(src, 'a.unknown', void 0);
- balUtil.setDeep(src, 'a.b.c', 2);
- assert.deepEqual(expected, src, 'out value was as expected');
- return done();
- });
- });
-
- joe.describe('Group', function(describe, it) {
- it('should work when tasks are specified manually', function(done) {
- var finished, firstTaskFinished, secondTaskFinished, tasks, total;
-
- firstTaskFinished = false;
- secondTaskFinished = false;
- finished = false;
- total = 2;
- tasks = new balUtil.Group(function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- tasks.total = 2;
- wait(1000, function() {
- firstTaskFinished = true;
- assert.equal(true, secondTaskFinished, 'the first task ran second as expected');
- return tasks.complete();
- });
- wait(500, function() {
- secondTaskFinished = true;
- assert.equal(false, firstTaskFinished, 'the second task ran first as expected');
- return tasks.complete();
- });
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- return wait(2000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should work when run synchronously', function(done) {
- var finished, firstTaskFinished, firstTaskRun, secondTaskFinished, secondTaskRun, tasks, total;
-
- firstTaskRun = false;
- secondTaskRun = false;
- firstTaskFinished = false;
- secondTaskFinished = false;
- finished = false;
- total = 2;
- tasks = new balUtil.Group(function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- tasks.push(function(complete) {
- firstTaskRun = true;
- assert.equal(false, secondTaskRun, 'the first task ran first as expected');
- return wait(1000, function() {
- firstTaskFinished = true;
- assert.equal(false, secondTaskFinished, 'the first task completed first as expected');
- return complete();
- });
- });
- tasks.push(function(complete) {
- secondTaskRun = true;
- assert.equal(true, firstTaskRun, 'the second task ran second as expected');
- return wait(500, function() {
- secondTaskFinished = true;
- assert.equal(true, firstTaskFinished, 'the second task completed second as expected');
- return complete();
- });
- });
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- tasks.sync();
- assert.equal(true, tasks.isRunning(), 'isRunning() returned true');
- return wait(2000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should work when run synchronously via run', function(done) {
- var finished, firstTaskFinished, firstTaskRun, secondTaskFinished, secondTaskRun, tasks, total;
-
- firstTaskRun = false;
- secondTaskRun = false;
- firstTaskFinished = false;
- secondTaskFinished = false;
- finished = false;
- total = 2;
- tasks = new balUtil.Group(function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- tasks.push(function(complete) {
- firstTaskRun = true;
- assert.equal(false, secondTaskRun, 'the first task ran first as expected');
- return wait(1000, function() {
- firstTaskFinished = true;
- assert.equal(false, secondTaskFinished, 'the first task completed first as expected');
- return complete();
- });
- });
- tasks.push(function(complete) {
- secondTaskRun = true;
- assert.equal(true, firstTaskRun, 'the second task ran second as expected');
- return wait(500, function() {
- secondTaskFinished = true;
- assert.equal(true, firstTaskFinished, 'the second task completed second as expected');
- return complete();
- });
- });
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- tasks.run('sync');
- assert.equal(true, tasks.isRunning(), 'isRunning() returned true');
- return wait(2000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should work when run asynchronously', function(done) {
- var finished, firstTaskFinished, firstTaskRun, secondTaskFinished, secondTaskRun, tasks, total;
-
- firstTaskRun = false;
- secondTaskRun = false;
- firstTaskFinished = false;
- secondTaskFinished = false;
- finished = false;
- total = 2;
- tasks = new balUtil.Group(function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- tasks.push(function(complete) {
- firstTaskRun = true;
- assert.equal(false, secondTaskRun, 'the first task ran first as expected');
- return wait(1000, function() {
- firstTaskFinished = true;
- assert.equal(true, secondTaskFinished, 'the first task completed second as expected');
- return complete();
- });
- });
- tasks.push(function(complete) {
- secondTaskRun = true;
- assert.equal(true, firstTaskRun, 'the second task ran second as expected');
- return wait(500, function() {
- secondTaskFinished = true;
- assert.equal(false, firstTaskFinished, 'the second task completed first as expected');
- return complete();
- });
- });
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- tasks.async();
- assert.equal(true, tasks.isRunning(), 'isRunning() returned true');
- return wait(2000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should handle errors correctly', function(done) {
- var finished, firstTaskFinished, firstTaskRun, secondTaskFinished, secondTaskRun, tasks, total;
-
- firstTaskRun = false;
- secondTaskRun = false;
- firstTaskFinished = false;
- secondTaskFinished = false;
- finished = false;
- total = 1;
- tasks = new balUtil.Group(function(err) {
- assert.equal(true, err !== null, 'an error is present');
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- tasks.push(function(complete) {
- firstTaskRun = true;
- assert.equal(false, secondTaskRun, 'the first task ran first as expected');
- return wait(1000, function() {
- firstTaskFinished = true;
- assert.equal(false, secondTaskFinished, 'the first task completed first as expected');
- return complete();
- });
- });
- tasks.push(function(complete) {
- secondTaskRun = true;
- assert.equal(true, firstTaskRun, 'the second task ran second as expected');
- return wait(500, function() {
- secondTaskFinished = true;
- assert.equal(true, firstTaskFinished, 'the second task completed second as expected');
- return complete(new Error('deliberate error'));
- });
- });
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- tasks.sync();
- assert.equal(true, tasks.isRunning(), 'isRunning() returned true');
- return wait(2000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(false, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should work with optional completion callbacks', function(done) {
- var finished, tasks, total;
-
- finished = false;
- total = 2;
- tasks = new balUtil.Group(function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- tasks.push(function(done) {
- return done();
- });
- tasks.push(function() {});
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- tasks.sync();
- return wait(5000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should work when specifying contexts', function(done) {
- var finished, tasks, total;
-
- finished = false;
- total = 2;
- tasks = new balUtil.Group(function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- tasks.push({
- blah: 1
- }, function() {
- return assert.equal(1, this.blah, 'context was applied correctly');
- });
- tasks.push({
- blah: 2
- }, function() {
- return assert.equal(2, this.blah, 'context was applied correctly');
- });
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- tasks.sync();
- return wait(5000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should push and run synchronous tasks correctly', function(done) {
- var finished, firstTaskFinished, firstTaskRun, secondTaskFinished, secondTaskRun, tasks, total;
-
- firstTaskRun = false;
- secondTaskRun = false;
- firstTaskFinished = false;
- secondTaskFinished = false;
- finished = false;
- total = 2;
- tasks = new balUtil.Group('serial', function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- assert.equal('serial', tasks.mode, 'mode was correctly set to serial');
- tasks.pushAndRun(function(complete) {
- firstTaskRun = true;
- assert.equal(false, secondTaskRun, 'the first task ran first as expected');
- return wait(1000, function() {
- firstTaskFinished = true;
- assert.equal(false, secondTaskFinished, 'the first task completed first as expected');
- return complete();
- });
- });
- assert.equal(true, tasks.isRunning(), 'isRunning() returned true');
- tasks.pushAndRun(function(complete) {
- secondTaskRun = true;
- assert.equal(true, firstTaskRun, 'the second task ran second as expected');
- return wait(500, function() {
- secondTaskFinished = true;
- assert.equal(true, firstTaskFinished, 'the second task completed second as expected');
- return complete();
- });
- });
- return wait(4000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should push and run asynchronous tasks correctly (queued)', function(done) {
- var finished, firstTaskFinished, firstTaskRun, secondTaskFinished, secondTaskRun, tasks, total;
-
- firstTaskRun = false;
- secondTaskRun = false;
- firstTaskFinished = false;
- secondTaskFinished = false;
- finished = false;
- total = 2;
- tasks = new balUtil.Group('parallel', function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- assert.equal('parallel', tasks.mode, 'mode was correctly set to parallel');
- tasks.pushAndRun(function(complete) {
- firstTaskRun = true;
- assert.equal(false, secondTaskRun, 'the first task ran first as expected');
- return wait(1000, function() {
- firstTaskFinished = true;
- assert.equal(true, secondTaskFinished, 'the first task completed second as expected');
- return complete();
- });
- });
- assert.equal(true, tasks.isRunning(), 'isRunning() returned true');
- tasks.pushAndRun(function(complete) {
- secondTaskRun = true;
- assert.equal(true, firstTaskRun, 'the second task ran second as expected');
- return wait(500, function() {
- secondTaskFinished = true;
- assert.equal(false, firstTaskFinished, 'the second task completed first as expected');
- return complete();
- });
- });
- return wait(4000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- it('should push and run synchronous tasks correctly (multiple times)', function(done) {
- var finished, tasks, total;
-
- finished = 0;
- total = 2;
- tasks = new balUtil.Group('serial', {
- autoClear: true
- }, function(err) {
- if (err) {
- return done(err);
- }
- return ++finished;
- });
- assert.equal('serial', tasks.mode, 'mode was correctly set to serial');
- assert.equal(true, tasks.autoClear, 'autoClear was correctly set to true');
- tasks.pushAndRun(function(complete) {
- return complete();
- });
- wait(500, function() {
- tasks.pushAndRun(function(complete) {
- return wait(500, function() {
- return complete();
- });
- });
- return assert.equal(true, tasks.isRunning(), 'isRunning() returned true');
- });
- return wait(2000, function() {
- assert.equal(total, finished, 'it exited the correct number of times');
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(false, tasks.hasCompleted(), 'hasCompleted() returned false');
- assert.equal(false, tasks.hasExited(), 'hasExited() returned false');
- return done();
- });
- });
- it('should work when running ten thousand tasks synchronously', function(done) {
- var finished, i, tasks, total, _i;
-
- finished = false;
- total = 10000;
- tasks = new balUtil.Group(function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- for (i = _i = 0; 0 <= total ? _i < total : _i > total; i = 0 <= total ? ++_i : --_i) {
- tasks.push(function(complete) {
- return complete();
- });
- }
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- tasks.sync();
- return wait(5000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- return it('should work when running ten thousand tasks asynchronously', function(done) {
- var finished, i, tasks, total, _i;
-
- finished = false;
- total = 10000;
- tasks = new balUtil.Group(function(err) {
- if (err) {
- return done(err);
- }
- assert.equal(false, finished, 'the group of tasks only finished once');
- return finished = true;
- });
- for (i = _i = 0; 0 <= total ? _i < total : _i > total; i = 0 <= total ? ++_i : --_i) {
- tasks.push(function(complete) {
- return setTimeout(complete, 50);
- });
- }
- assert.equal(0, tasks.completed, 'no tasks should have started yet');
- tasks.async();
- return wait(5000, function() {
- assert.equal(total, tasks.completed, 'the expected number of tasks ran ' + ("" + tasks.completed + "/" + total));
- assert.equal(false, tasks.isRunning(), 'isRunning() returned false');
- assert.equal(true, tasks.hasCompleted(), 'hasCompleted() returned true');
- assert.equal(true, tasks.hasExited(), 'hasExited() returned true');
- return done();
- });
- });
- });
-
-}).call(this);
diff --git a/out/test/html.test.js b/out/test/html.test.js
deleted file mode 100644
index 310827e..0000000
--- a/out/test/html.test.js
+++ /dev/null
@@ -1,47 +0,0 @@
-// Generated by CoffeeScript 1.6.2
-(function() {
- var assert, balUtil, joe, wait;
-
- assert = (typeof require === "function" ? require('assert') : void 0) || this.assert;
-
- joe = (typeof require === "function" ? require('joe') : void 0) || this.joe;
-
- balUtil = (typeof require === "function" ? require(__dirname + '/../lib/balutil') : void 0) || this.balUtil;
-
- wait = function(delay, fn) {
- return setTimeout(fn, delay);
- };
-
- joe.suite('html', function(suite, test) {
- test('replaceElement', function() {
- var actual, expected, replaceElementCallback, source;
-
- source = "breakfast\n