Skip to content
Browse files

Test for subdependency

  • Loading branch information...
1 parent 5d09132 commit 540c7560c573b173d39d856e7eb9785ecc904b6a @mixu committed Jul 28, 2012
Showing with 24 additions and 9 deletions.
  1. +7 −8 lib/package.js
  2. +17 −1 test/package.test.js
View
15 lib/package.js
@@ -42,14 +42,15 @@ Package.prototype.dependency = function(name, contextPath) {
} else {
var child = new Package();
- var location = resolver.resolve(contextPath, name);
- resolver.expand(location, function(main, files, dependencies) {
+ var basePath = resolver.resolve(contextPath, name);
+ resolver.expand(basePath, function(main, files, dependencies) {
console.log(arguments);
child.name = name;
child.files = files;
- child.main = main;
+ child.main = main.replace(new RegExp('^'+basePath), '');
+ child.basepath = basePath;
dependencies.forEach(function(dep) {
- child.dependency(dep, location);
+ child.dependency(dep, basePath);
});
self.children.push(child);
@@ -92,11 +93,9 @@ Package.prototype._runHandlers = function(selfId, onDone) {
}
tasks.push( function(done) {
opts.filename = filename;
- if (opts.relative) {
- opts.relativeFilename = opts.relative(filename);
- }
+ opts.relativeFilename = opts.relative(filename);
matching[0].handler(opts, function(data) {
- result[filename] = data;
+ result[opts.relativeFilename] = data;
done();
});
});
View
18 test/package.test.js
@@ -40,7 +40,7 @@ exports['given a group'] = {
done();
},
-*/
+
'can add a dependency on a package that is a directory (index.js)': function(done) {
var p = this.p;
p.dependency('foo', __dirname+'/fixtures/expandindex/');
@@ -54,6 +54,22 @@ exports['given a group'] = {
done();
},
+*/
+ 'when a dependency has a (sub)dependency, it gets resolved as well': function(done) {
+ var p = this.p;
+ p.dependency('foo', __dirname+'/fixtures/hassubdependency/');
+ console.log('pacakge', util.inspect(p, null, 5, true));
+
+ var result = [];
+ p.render(result, function(selfId) {
+ console.log('result', util.inspect(result, null, 5, true));
+
+ });
+
+ done();
+ },
+
+
/*
'can add a dependency on a package that is a directory (package.json)': function(done) {
var g = this.group;

0 comments on commit 540c756

Please sign in to comment.
Something went wrong with that request. Please try again.