1
0
Fork 0

Fixed package file resolution. Fixes #718, #720.

This commit is contained in:
Alan Plum 2014-01-09 19:06:15 +01:00 committed by Frank Celler
parent 56054d3e66
commit 1a5f4c98f2
1 changed files with 20 additions and 11 deletions

View File

@ -1082,25 +1082,34 @@ function require (path) {
return null;
}
// try to load the file
// try to load the file
var n;
if (p === "") {
n = "." + main + ".js";
}
else if (p[p.length - 1] === '/') {
n = p + main.substr(1) + ".js";
}
else {
n = p + main + ".js";
if (p !== "" && p[p.length - 1] === '/') {
p = p.substr(0, p.length - 1);
}
n = p + main + ".js";
if (fs.exists(n)) {
return { name: main,
path: 'file://' + n,
content: fs.read(n) };
}
n = p + main + "/index.js";
if (fs.exists(n)) {
return { name: main,
path: 'file://' + n,
content: fs.read(n) };
}
n = p + main;
if (fs.exists(n)) {
return { name: main,
path: 'file://' + n,
content: fs.read(n) };
}
return null;
};