diff --git a/lib/api.js b/lib/api.js index 322ec243..687c512d 100644 --- a/lib/api.js +++ b/lib/api.js @@ -351,9 +351,20 @@ var api = new (function () { } }; - this.packageTask = function (name, version, definition) { - return new jake.PackageTask(name, version, definition); - }; + function createApi(jakeTaskConstructorGetter) { + return function() { + var jakeTaskConstructor = jakeTaskConstructorGetter(); + + var ctor = function () {} + , t; + ctor.prototype = jakeTaskConstructor.prototype; + t = new ctor(); + jakeTaskConstructor.apply(t, arguments); + return t; + }; + } + + this.packageTask = createApi(function() { return jake.PackageTask;}); this.publishTask = function (name, prereqs, opts, definition) { return new jake.PublishTask(name, prereqs, opts, definition); @@ -368,14 +379,7 @@ var api = new (function () { return new jake.WatchTask(name, taskNames, definition); }; - this.testTask = function () { - var ctor = function () {} - , t; - ctor.prototype = jake.TestTask.prototype; - t = new ctor(); - jake.TestTask.apply(t, arguments); - return t; - }; + this.testTask = createApi(function() { return jake.TestTask;}); })(); diff --git a/lib/jake.js b/lib/jake.js index 22a1bc71..e34d938b 100644 --- a/lib/jake.js +++ b/lib/jake.js @@ -45,15 +45,15 @@ var Invocation = function (taskName, args) { // Globalize jake and top-level API methods (e.g., `task`, `desc`) utils.mixin(global, api); -// Also add top-level API methods to exported object for those who don't want to -// use the globals -utils.mixin(jake, api); - // Copy utils onto base jake utils.mixin(jake, utils); // File utils should be aliased directly on base jake as well utils.mixin(jake, utils.file); +// Also add top-level API methods to exported object for those who don't want to +// use the globals (`file` here will overwrite the 'file' utils namespace) +utils.mixin(jake, api); + utils.mixin(jake, new (function () { this._invocationChain = []; diff --git a/lib/publish_task.js b/lib/publish_task.js index f8334719..d062b783 100644 --- a/lib/publish_task.js +++ b/lib/publish_task.js @@ -63,6 +63,7 @@ var PublishTask = function () { this.prereqs = prereqs; this.packageFiles = new FileList(); this.publishCmd = opts.publishCmd || 'npm publish %filename'; + this.publishMessage = opts.publishMessage || 'BOOM! Published.'; this.gitCmd = opts.gitCmd || 'git'; this.versionFiles = opts.versionFiles || ['package.json']; this.scheduleDelay = 5000; @@ -253,15 +254,26 @@ PublishTask.prototype = new (function () { cmd = self.publishCmd.replace(/%filename/gi, filename); } - // Hackity hack -- NPM publish sometimes returns errror like: - // Error sending version data\nnpm ERR! - // Error: forbidden 0.2.4 is modified, should match modified time - setTimeout(function () { - jake.exec(cmd, function () { - console.log('BOOM! Published.'); + if (typeof cmd == 'function') { + cmd(function (err) { + if (err) { + throw err; + } + console.log(self.publishMessage); complete(); - }, {printStdout: true, printStderr: true}); - }, self.scheduleDelay); + }); + } + else { + // Hackity hack -- NPM publish sometimes returns errror like: + // Error sending version data\nnpm ERR! + // Error: forbidden 0.2.4 is modified, should match modified time + setTimeout(function () { + jake.exec(cmd, function () { + console.log(self.publishMessage); + complete(); + }, {printStdout: true, printStderr: true}); + }, self.scheduleDelay); + } }); task('cleanup', {async: true}, function () { diff --git a/package.json b/package.json index 48ae3955..153abd8a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "make", "rake" ], - "version": "8.0.13", + "version": "8.0.15", "author": "Matthew Eernisse (http://fleegix.org)", "license": "Apache-2.0", "bin": { @@ -24,7 +24,7 @@ "preferGlobal": true, "dependencies": { "filelist": "0.0.x", - "minimatch": "0.2.x", + "minimatch": "3.x", "chalk": "0.4.x", "utilities": "1.0.x", "async": "0.9.x"