Comparing version
@@ -10,3 +10,4 @@ /*COMMAND METHODS*/ | ||
, type = args.shift(); | ||
callback(type.toLowerCase(), args.join(',').replace(/\s|\,(?=\,)/g,'').split(',').filter(function(x){return x !== '';})); | ||
// Display the help message by default. | ||
callback(type && type.toLowerCase() || 'help', args.join(',').replace(/\s|\,(?=\,)/g,'').split(',').filter(function(x){return x !== '';})); | ||
} | ||
@@ -13,0 +14,0 @@ |
102
lib/ender.js
@@ -14,40 +14,9 @@ var colors = require('colors') | ||
//define base api | ||
API = { | ||
'.': function () { | ||
API.refresh.apply(this, arguments); | ||
} | ||
, '+': function () { | ||
API.add.apply(this, arguments); | ||
} | ||
, '-b': function () { | ||
API.build.apply(this, arguments); | ||
} | ||
, '-a': function () { | ||
API.async.apply(this, arguments); | ||
} | ||
, '-j': function () { | ||
API.just.apply(this, arguments); | ||
} | ||
, '-h': function () { | ||
API.help.apply(this, arguments); | ||
} | ||
, '-d': function () { | ||
API.remove.apply(this, arguments); | ||
} | ||
, '-i': function () { | ||
list: function () { | ||
API.info.apply(this, arguments); | ||
} | ||
, list: function () { | ||
API.info.apply(this, arguments); | ||
} | ||
, set: function () { | ||
@@ -62,3 +31,3 @@ API.add.apply(this, arguments); | ||
, add: function (packages) { | ||
, add: function (packages, name, _isAsync, callback) { | ||
if (!packages.length) { | ||
@@ -85,5 +54,7 @@ return console.log('error: you must specify a package to add.'.yellow); | ||
ENDER.file.assemble(modules.concat(queue), ENDER.get.buildType(type) == 'async', context, function (source) { | ||
var built = 0; | ||
ENDER.file.output(source, 'ender'); | ||
ENDER.file.uglify(source, ENDER.file.output, 'ender.min'); | ||
var built = 0, isComplete = function () { | ||
if (++built === 2) callback && callback(); | ||
}; | ||
ENDER.file.output(source, name || 'ender', isComplete); | ||
ENDER.file.uglify(source, ENDER.file.output, (name || 'ender') + '.min', isComplete); | ||
}); | ||
@@ -97,3 +68,3 @@ }); | ||
, remove: function (packages) { | ||
, remove: function (packages, name, _isAsync, callback) { | ||
if (!packages.length) { | ||
@@ -121,5 +92,7 @@ return console.log('error: you must specify a package to remove.'.yellow); | ||
ENDER.file.assemble(modules, type == '-a' || type == 'async', context, function (source) { | ||
var built = 0; | ||
ENDER.file.output(source, 'ender'); | ||
ENDER.file.uglify(source, ENDER.file.output, 'ender.min'); | ||
var built = 0, isComplete = function () { | ||
if (++built === 2) callback && callback(); | ||
}; | ||
ENDER.file.output(source, name || 'ender', isComplete); | ||
ENDER.file.uglify(source, ENDER.file.output, (name || 'ender') + '.min', isComplete); | ||
}); | ||
@@ -178,2 +151,5 @@ } | ||
, just: function (packages, name, noop, callback) { | ||
if (packages.length == 1 && packages[0] == '.') { | ||
return API.refresh('-j'); | ||
} | ||
API.build.call(this, packages, name, false, function () { | ||
@@ -191,3 +167,3 @@ ENDER.file.removeDir('node_modules', function () { | ||
if (packages.length == 1 && packages[0] == '.') { | ||
return ENDER.refresh('-b'); | ||
return API.refresh('-b'); | ||
} | ||
@@ -216,3 +192,43 @@ packages = ENDER.util.unique(ENDER.get.special(packages)); | ||
//Export base API methods | ||
var _API = ENDER.util.merge(module.exports, API); | ||
//Extend API with shortcuts for cli | ||
ENDER.util.merge(API, { | ||
'.': function () { | ||
_API.refresh.apply(this, arguments); | ||
} | ||
, '+': function () { | ||
_API.add.apply(this, arguments); | ||
} | ||
, '-b': function () { | ||
_API.build.apply(this, arguments); | ||
} | ||
, '-a': function () { | ||
_API.async.apply(this, arguments); | ||
} | ||
, '-j': function () { | ||
_API.just.apply(this, arguments); | ||
} | ||
, '-h': function () { | ||
_API.help.apply(this, arguments); | ||
} | ||
, '-d': function () { | ||
_API.remove.apply(this, arguments); | ||
} | ||
, '-i': function () { | ||
_API.info.apply(this, arguments); | ||
} | ||
}); | ||
//Expose exec which can use shorcut flags | ||
module.exports.exec = function (cmd, name, callback) { | ||
@@ -224,2 +240,2 @@ API.welcome(); | ||
}); | ||
}; | ||
} |
@@ -43,4 +43,11 @@ /* UTILITY METHODS */ | ||
, merge: function (a, b) { | ||
for (var k in b) { | ||
a[k] = b[k]; | ||
} | ||
return a; | ||
} | ||
, containsAll: function (a, b) { | ||
for(var i = b.length; i--;) { | ||
for (var i = b.length; i--;) { | ||
if (a.indexOf(b[i]) == -1) return false | ||
@@ -47,0 +54,0 @@ } |
{ | ||
"name": "ender", | ||
"description": "next level JavaScript modules", | ||
"version": "0.2.1", | ||
"version": "0.2.3", | ||
"authors": ["Dustin Diaz <@ded>", "Jacob Thornton <@fat>"], | ||
@@ -6,0 +6,0 @@ "keywords": ["ender", "modules", "builder", "framework", "packager"], |
@@ -41,3 +41,3 @@ <div id="intro"></div> | ||
Ender provides a whole slew of methods for building, updating, and sliming down your libraries. Let's take a look... | ||
Ender provides a whole slew of methods for building, updating, and slimming down your libraries. Let's take a look... | ||
@@ -206,3 +206,3 @@ <h3>Build (<code>-b, build</code>)</h3> | ||
rand: function () { | ||
return this.elements[Math.floor(Math.random() * (this.elements.length + 1))]; | ||
return this.elements[Math.floor(Math.random() * this.elements.length)]; | ||
} | ||
@@ -209,0 +209,0 @@ }, true); |
Sorry, the diff of this file is not supported yet
47897
27.88%15
25%842
50.9%7
16.67%