text: // Generated by CoffeeScript 1.4.0
  (function() {
    var Module, basename, dirname, extname, invalidDirs, isAbsolute, join, modulePaths, modulerize, repl, resolve, sep, _ref,
      __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
  
    Module = require('module');
  
    _ref = require('path'), join = _ref.join, extname = _ref.extname, dirname = _ref.dirname, basename = _ref.basename, resolve = _ref.resolve, sep = _ref.sep;
  
    isAbsolute = function(path) {
      return /^\//.test(path);
    };
  
    modulerize = function(id, filename) {
      var ext, modName;
      if (filename == null) {
        filename = id;
      }
      ext = extname(filename);
      modName = join(dirname(id), basename(id, ext));
      return modName.replace(/\\/g, '/');
    };
  
    modulePaths = Module._nodeModulePaths(process.cwd());
  
    invalidDirs = ['/', '.'];
  
    repl = {
      id: 'repl',
      filename: join(process.cwd(), 'repl'),
      paths: modulePaths
    };
  
    module.exports = function(request, parent) {
      var dir, filename, id, index, paths, _, _ref1;
      if (parent == null) {
        parent = repl;
      }
      _ref1 = Module._resolveLookupPaths(request, parent), _ = _ref1[0], paths = _ref1[1];
      filename = Module._findPath(request, paths);
      if (!filename) {
        throw new Error("Cannot find module: " + request + ". Have you run `npm install .` ?");
      }
      dir = filename;
      while (__indexOf.call(invalidDirs, dir) < 0 && __indexOf.call(modulePaths, dir) < 0) {
        dir = dirname(dir);
      }
      if (__indexOf.call(invalidDirs, dir) >= 0) {
        index = filename.lastIndexOf("" + sep + request);
        if (index > 0) {
          dir = filename.substring(0, index);
          modulePaths.push(dir);
        } else {
          throw new Error("Load path not found for " + filename);
        }
      }
      id = filename.replace("" + dir + sep, '');
      return [modulerize(id, filename), filename];
    };
  
    module.exports.paths = function(filename) {
      return Module._nodeModulePaths(dirname(filename));
    };
  
    module.exports.modulerize = modulerize;
  
  }).call(this);
  