Permalink
Browse files

Fix package.json searching

  • Loading branch information...
1 parent b47105f commit d8413f4d95c222b669fc43cb2c924a09627dd1dd @kriszyp committed Aug 26, 2010
Showing with 8 additions and 6 deletions.
  1. +8 −6 lib/nodules.js
View
@@ -46,18 +46,20 @@ function EnginePackage(engine){
var enginePackage = this;
this.useLocal= function(){
var packageJson = "{}",
- path = ".";
- function findPackage(directory){
- path = fs.absolute(directory);
+ path = fs.absolute(".");
+ function findPackage(path){
try{
packageJson = fs.read(path + "/package.json");
}catch(e){
- return findPackage(directory + "/..");
+ if(path.lastIndexOf('/') < 1 && path.lastIndexOf('\\') < 1){
+ throw new Error("Couldn't find package.json");
+ }
+ return findPackage(path.substring(0, Math.max(path.lastIndexOf('/'),path.lastIndexOf('\\'))));
}
return path;
}
try{
- path = findPackage(".");
+ path = findPackage(path);
}catch(e){}
try{
var parsed = JSON.parse(packageJson);
@@ -720,9 +722,9 @@ function readModuleFile(path, uri){
return 'process.dlopen("' + path + '", exports);';
}
catch(nodeE){
- throw e;
}
}
+ throw e;
}
function possibleChange(oldstat, newstat){
if(oldstat.mtime.getTime() !== newstat.mtime.getTime() && waitingOn === 0){

0 comments on commit d8413f4

Please sign in to comment.