Permalink
Browse files

determine main module more reliably

  • Loading branch information...
dantebronto committed Jan 30, 2011
1 parent 9bf3074 commit 8c918b6a8f21a704baa33899bccc0d3158c481eb
Showing with 6 additions and 3 deletions.
  1. +3 −1 README.textile
  2. +3 −2 lib/picard/config.js
View
@@ -4,7 +4,9 @@ h1. Picard: A Micro-framework for node.js
p. Picard uses Haml thanks to creationix's haml-js project.
-p. Check the examples to see what is possible.
+p. Check the examples to see what is possible.
+
+p. master branch was last tested against node.js v0.3.7.
h3. License
View
@@ -29,8 +29,9 @@ var Conf = {
},
rootDir: function(){
try {
- var fullPath = process.mainModule.filename
- return require('path').dirname(fullPath)
+ var topMod = module.parent
+ while ( topMod.parent ) topMod = topMod.parent
+ return require('path').dirname(topMod.filename)
} catch(e) {
throw "Must set root directory via Picard.set('root', __dirname) or similar"
}

0 comments on commit 8c918b6

Please sign in to comment.