Skip to content

Commit

Permalink
Fixes #54, main path config for packages was not in line with the spe…
Browse files Browse the repository at this point in the history
…c or npm. Will cause some adjustments by people who use package config, but now impl is in line with the packages 1.1 spec draft and npm.
  • Loading branch information
jrburke committed Dec 24, 2010
1 parent 3548c88 commit 2bd9d9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 4 additions & 6 deletions require.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var require, define;
//Normalize package paths.
pkgObj.location = pkgObj.location || pkgObj.name;
pkgObj.lib = pkgObj.lib || "lib";
pkgObj.main = pkgObj.main || "main";
pkgObj.main = pkgObj.main || "lib/main";

packages[pkgObj.name] = pkgObj;
}
Expand Down Expand Up @@ -1108,14 +1108,12 @@ var require, define;
syms.splice(0, i, paths[parentModule]);
break;
} else if ((pkg = packages[parentModule])) {
//pkg can have just a string value to the path
//or can be an object with props:
//main, lib, name, location.
pkgPath = pkg.location + '/' + pkg.lib;
//If module name is just the package name, then looking
//for the main module.
if (moduleName === pkg.name) {
pkgPath += '/' + pkg.main;
pkgPath = pkg.location + '/' + pkg.main;
} else {
pkgPath = pkg.location + '/' + pkg.lib;
}
syms.splice(0, i, pkgPath);
break;
Expand Down
9 changes: 5 additions & 4 deletions tests/packages/packages-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require({
name: 'beta',
location: 'beta/0.2',
lib: 'scripts',
main: 'beta'
main: 'scripts/beta'
},
'dojox/chair',
{
Expand All @@ -24,20 +24,21 @@ require({
{
name: 'bar',
location: 'bar/0.4',
lib: 'scripts'
lib: 'scripts',
main: 'scripts/main'
},
{
name: 'foo',
location: 'foo'
},
{
name: 'funky',
main: '../index'
main: 'index'
},
{
name: 'baz',
location: 'baz',
main: 'index'
main: 'lib/index'
},
{
name: 'dojox/window',
Expand Down

0 comments on commit 2bd9d9a

Please sign in to comment.