Search node_modules in parent directories until the root is reached (fixes #956)
Showing
1 changed file
with
8 additions
and
1 deletions
... | @@ -248,7 +248,14 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -248,7 +248,14 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
248 | return resolveFile(path, fs.pathJoin(phantom.casperPath, 'modules')); | 248 | return resolveFile(path, fs.pathJoin(phantom.casperPath, 'modules')); |
249 | } | 249 | } |
250 | function nodeModulePath(path) { | 250 | function nodeModulePath(path) { |
251 | return resolveFile(path, fs.pathJoin(getCurrentScriptRoot(), 'node_modules')); | 251 | var resolved, prevBaseDir; |
252 | var baseDir = getCurrentScriptRoot(); | ||
253 | do { | ||
254 | resolved = resolveFile(path, fs.pathJoin(baseDir, 'node_modules')); | ||
255 | prevBaseDir = baseDir; | ||
256 | baseDir = fs.absolute(fs.pathJoin(prevBaseDir, '..')); | ||
257 | } while (!resolved && baseDir !== '/' && baseDir !== prevBaseDir); | ||
258 | return resolved; | ||
252 | } | 259 | } |
253 | function localModulePath(path) { | 260 | function localModulePath(path) { |
254 | return resolveFile(path, phantom.casperScriptBaseDir || fs.workingDirectory); | 261 | return resolveFile(path, phantom.casperScriptBaseDir || fs.workingDirectory); | ... | ... |
-
Please register or sign in to post a comment