1 var path = require('path');
3 module.exports = function (start, opts) {
4 var modules = opts.moduleDirectory
5 ? [].concat(opts.moduleDirectory)
9 if (/^([A-Za-z]:)/.test(start)) {
11 } else if (/^\\\\/.test(start)) {
14 var splitRe = process.platform === 'win32' ? /[\/\\]/ : /\/+/;
16 // ensure that `start` is an absolute path at this point,
17 // resolving againt the process' current working directory
18 start = path.resolve(start);
20 var parts = start.split(splitRe);
23 for (var i = parts.length - 1; i >= 0; i--) {
24 if (modules.indexOf(parts[i]) !== -1) continue;
25 dirs = dirs.concat(modules.map(function(module_dir) {
26 return prefix + path.join(
27 path.join.apply(path, parts.slice(0, i + 1)),
32 if (process.platform === 'win32'){
33 dirs[dirs.length-1] = dirs[dirs.length-1].replace(":", ":\\");
35 return dirs.concat(opts.paths);