Resolves a relative path in the context of a module into an absolute path

@param {string} moduleName
@param {string} relativePath the relative path inside the module
@returns {string|null}
502312
function resolvePath (moduleName, relativePath)
{
  if (! moduleName) {
    return null;
  }

  if (! relativePath) {
    return null;
  }

  const mainPath = require.resolve(moduleName);
  if (! mainPath) {
    return null;
  }

  const rootLocations = [];
  const dirs = mainPath.split(path.sep);
  let lastSegment = dirs.pop();
  while (lastSegment) {
    const location = dirs.concat(['package.json']).join(path.sep);
    rootLocations.push(location);
    lastSegment = dirs.pop();
  }

  for(const location of rootLocations) {
    if (fs.existsSync(location)) {
      const cli = path.resolve(path.dirname(location), relativePath);
      if (fs.existsSync(cli)) {
        return cli;
      }
    }
  }

  return null;
}
90881
function resolveGitRoot(filepath) {
    var relativeToGit, repoId;

    // No git repo cloned, or file is not in a git repository
    if (!GIT_TMP || !pathUtil.isInRoot(GIT_TMP, filepath)) return null;

    // Extract first directory (is the repo id)
    relativeToGit = path.relative(GIT_TMP, filepath);
    repoId = _.first(relativeToGit.split(path.sep));
    if (!repoId) return;

    // Return an absolute file
    return path.resolve(GIT_TMP, repoId);
}
1128319
function resolveRelative(base, filePath) {
	return getBasePath(base)
	.then(basePath => tryFile(path.resolve(basePath, filePath)));
}
709319
function relative(path){
  var startX = 0
  var startY = 0
  var x = 0
  var y = 0

  return path.map(function(seg){
    seg = seg.slice()
    var type = seg[0]
    var command = type.toLowerCase()

    // is absolute
    if (type != command) {
      seg[0] = command
      switch (type) {
        case 'A':
          seg[6] -= x
          seg[7] -= y
          break
        case 'V':
          seg[1] -= y
          break
        case 'H':
          seg[1] -= x
          break
        default:
          for (var i = 1; i < seg.length;) {
            seg[i++] -= x
            seg[i++] -= y
          }
      }
    }

    // update cursor state
    switch (command) {
      case 'z':
        x = startX
        y = startY
        break
      case 'h':
        x += seg[1]
        break
      case 'v':
        y += seg[1]
        break
      case 'm':
        x += seg[1]
        y += seg[2]
        startX += seg[1]
        startY += seg[2]
        break
      default:
        x += seg[seg.length - 2]
        y += seg[seg.length - 1]
    }

    return seg
  })
}
998427
function resolvePath(filepath) {
  filepath = filepath.replace(RE_TRAILING, '');
  const cwd = process.cwd();
  const npmPackage = filepath.includes('node_modules');

  // Find nearest node_modules directory
  if (npmPackage) {
    const parts = filepath.split(path.sep);
    let idx = parts.lastIndexOf('node_modules');

    if (idx < parts.length - 1) idx += 2;
    // Handle scoped
    if (parts[idx - 1].charAt(0) == '@') idx++;

    const dir = parts.slice(0, idx).join(path.sep);

    // Installed packages must have manifest, otherwise continue
    if (exists(path.join(dir, 'package.json'))) return dir;
  }

  // Find nearest directory with node_modules subdirectory
  if (filepath.includes(cwd)) {
    let depth = maxFileSystemDepth;
    let dir = filepath;
    let parent = '';

    while (true) {
      parent = path.dirname(dir);
      // Stop if we hit max file system depth or root
      // Convert to lowercase to fix problems on Windows
      if (!--depth || parent.toLowerCase() === dir.toLowerCase()) {
        break;
      }

      // Stop at nearest directory with node_modules or cwd
      if (dir == cwd || exists(path.resolve(dir, 'node_modules'))) return dir;

      // Walk
      dir = parent;
    }
  }

  // Return project directory if file isn't a project file
  return cwd;
}
368226
function resolveLocalPath(importPath, fromFile, options) {
  let appOrAddonDirIndex = fromFile.indexOf(options.ownerName, options.root.length);
  let prefix = fromFile.substring(0, appOrAddonDirIndex);
  let absolutePath = ensurePosixPath(path.resolve(prefix, importPath));
  return internalDep(absolutePath, options);
}
570740
function resolve(path, options, callback) {
        resolvePath(path, options, function (err, path) {
            if (err) return callback(err);
            callback(null, { path: path });
        });
    }
923458
function mkPath(absPath) {
    let localPrefix = absPath.substring(absPath.indexOf(dir_of_interest) + dir_of_interest.length)
    if (localPrefix.startsWith("/")) localPrefix = localPrefix.substring(1)
    return path.resolve(dir_of_interest,
        'node_modules',
        '@areslabs',
        'babel-plugin-import-css',
        'rncsscache',
        localPrefix + '.js'
    )
}
610357
async function assurePath (modulePath, resolve) {
  if (resolveCache[modulePath] === false) {
    return false
  } else if (!(modulePath in resolveCache)) {
    if (typeof resolve === 'function') {
      try {
        resolveCache[modulePath] = !!(await resolve(modulePath))
      } catch (e) {
        resolveCache[modulePath] = false
      }
    }
  }

  return resolveCache[modulePath]
}
1121437
function relativePath(from, to) {
  // console.log('relativePath:from: ' + from);
  // console.log('relativePath:to: ' + to);
  var relative = path.relative(from, to);
  if (!relative || relative.length < 1) {
    return relative;
  }
  var first = relative.substr(0, 1);
  if (first !== '.' && first !== '/') {
    relative = './' + relative;
  }

  // especially used for windows
  relative = relative.split(path.sep).join('/');

  return relative;
}
788722
def relative_path(path):
    
    return os.path.join(os.path.dirname(__file__), path)
352181
function extendResolvePath(basedir) {
    // using module internals isn't good, but restarting with corrected NODE_PATH looks more ugly, IMO
    module.paths.push(basedir);

    const _basedir = basedir.split('/'),
        size = basedir.length;
    let i = 0;

    while (size > i++) {
        const modulesPath = _basedir.slice(0, i).join('/') + '/node_modules';

        if (module.paths.indexOf(modulesPath) === -1) {
            module.paths.push(modulesPath);
        }
    }
}
948062
function assurePathSync (modulePath, resolveSync) {
  if (resolveCache[modulePath] === false) {
    return false
  } else if (!(modulePath in resolveCache)) {
    if (typeof resolveSync === 'function') {
      try {
        resolveCache[modulePath] = !!resolveSync(modulePath)
      } catch (e) {
        resolveCache[modulePath] = false
      }
    }
  }

  return resolveCache[modulePath]
}
95265
function View_resolve(toPath, fromPath) {
            var file = di.normalizePath(toPath),
                themes = this.config.themes.slice(),
                theme,
                re,
                filePath,
                normalizers = this.normalizers.slice(),
                isNormalized = false,
                path,
                pathRegex,
                pathReplace,
                trace = [];

            // file name normalizers
            while (normalizers.length) {
                path = di.normalizePath(normalizers.shift());
                pathReplace = path.replace(/\\/g, '\\\\');
                pathRegex = new RegExp(pathReplace);
                if (file.match(pathRegex)) {
                    file = file.replace(pathRegex, '').replace(this.suffix, '');
                    isNormalized = true;
                    break;
                }
            }
            // try normalize fromPath
            if (!isNormalized && !!fromPath) {
                normalizers = this.normalizers.slice();
                fromPath = di.normalizePath(fromPath);
                // file name normalizers
                while (normalizers.length) {
                    path = di.normalizePath(normalizers.shift());
                    pathReplace = path.replace(/\\/g, '\\\\');
                    pathRegex = new RegExp(pathReplace);
                    if (fromPath.match(pathRegex)) {
                        isNormalized = true;
                        break;
                    }
                }
            }

            // check themes
            if (isNormalized) {
                while (themes.length) {
                    theme = di.normalizePath(themes.shift() + '/');
                    pathReplace = theme.replace(/\\/g, '\\\\');
                    re = new RegExp('^' + pathReplace);
                    file = file.replace(re, '');

                    filePath = di.normalizePath(path + theme + '/' + file + this.config.suffix);
                    if (this.isFile(filePath)) {
                        return filePath;
                    }
                    trace.push({
                        theme: theme,
                        path: path,
                        filePath: filePath
                    });
                }
            }


            throw new error.HttpError(500, {
                from: fromPath,
                load: toPath,
                filePath: filePath,
                paths: this.paths,
                isNormalized: isNormalized,
                file: file,
                path: path,
                trace: trace,
                themes: this.config.themes
            }, "View.resolve: template don't exists");
        }
917623
def resolve(self, container: Container, fn: str) -> str:
        
        bug = self.__mgr_bug[container.bug]
        fn_orig = fn

        if not os.path.isabs(fn):
            fn = os.path.join(bug.source_dir, fn)
            logger.debug("converted relative path to absolute path: %s -> %s",
                         fn_orig, fn)

        return fn
553394
def _resolve_path(self, container: Container, filepath: str) -> str:
        
        bug = self.__mgr_bug[container.bug]
        filepath_orig = filepath

        if not os.path.isabs(filepath):
            filepath = os.path.join(bug.source_dir, filepath)
            logger.debug("converted relative path to absolute path: %s -> %s",
                         filepath_orig, filepath)

        return filepath
1285583
function resolveFilepath(filepath, baseDir) {
    if (baseDir) {
        var base = normalizeFilepath(path.resolve(baseDir));
        filepath = removePrefixFromFilepath(filepath, base);
        filepath = removePrefixFromFilepath(filepath, fs.realpathSync(base));
    }
    filepath.replace(/^\//, "");
    return filepath;
}