Permalink
Browse files

Merge pull request #149 from chakrit/master

Fix issue #144 Allow defining namespaces in multiple files instead of just one.
  • Loading branch information...
2 parents e3b9290 + e0b2440 commit 831b85fb3d219fc6599f6cb73b992f63917ca73a @mde mde committed Aug 17, 2012
Showing with 42 additions and 1 deletion.
  1. +1 −1 lib/api.js
  2. +14 −0 test/Jakefile
  3. +27 −0 test/namespace.js
View
@@ -147,7 +147,7 @@ var api = new (function () {
*/
this.namespace = function (name, scope) {
var curr = jake.currentNamespace
- , ns = new jake.Namespace(name, curr);
+ , ns = curr.childNamespaces[name] || new jake.Namespace(name, curr);
curr.childNamespaces[name] = ns;
jake.currentNamespace = ns;
scope();
View
@@ -197,4 +197,18 @@ namespace('vronk', function () {
});
});
+// define namespace
+namespace('one', function() {
+ task('one', function() {
+ console.log('one:one');
+ });
+});
+
+// modify namespace (add task)
+namespace('one', function() {
+ task('two', ['one:one'], function() {
+ console.log('one:two');
+ });
+});
+
View
@@ -0,0 +1,27 @@
+var assert = require('assert')
+ , h = require('./helpers')
+ , jake = {}
+ , utils = require('../lib/utils');
+
+utils.mixin(jake, utils);
+
+var tests = {
+ 'before': function() {
+ process.chdir('./test');
+ }
+
+, 'after': function() {
+ process.chdir('../');
+ }
+
+, 'test modifying a namespace by adding a new task': function(next) {
+ h.exec('../bin/cli.js one:two', function(out) {
+ assert.equal('one:one\none:two', out);
+ next();
+ });
+ }
+
+};
+
+module.exports = tests;
+

0 comments on commit 831b85f

Please sign in to comment.