lib/resolver/package.js
function resolveName(pkgpath) {
  pkgpath = pkgpath.replace(RE_TRAILING, '');

  const cwd = process.cwd();
  const parts = pkgpath.split(path.sep);
  const len = parts.length;

  let idx = 1;

  // Handle packages nested under root
  if (!pkgpath.includes('node_modules') && cwd != pkgpath) {
    // Increase by distance from root
    idx += path.relative(cwd, pkgpath).split(path.sep).length;
    // Handle scoped node_modules
  } else if (parts[len - 2].charAt(0) == '@') {
    idx = 2;
  }

  return parts.slice(len - idx).join(path.sep);
}
function resolveName(pkgpath) {
  pkgpath = pkgpath.replace(RE_TRAILING, '');

  const cwd = process.cwd();
  const parts = pkgpath.split(path.sep);
  const len = parts.length;

  let idx = 1;

  // Handle packages nested under root
  if (!pkgpath.includes('node_modules') && cwd != pkgpath) {
    // Increase by distance from root
    idx += path.relative(cwd, pkgpath).split(path.sep).length;
    // Handle scoped node_modules
  } else if (parts[len - 2].charAt(0) == '@') {
    idx = 2;
  }

  return parts.slice(len - idx).join(path.sep);
}
function resolveName ( pkgpath ) { pkgpath = pkgpath . replace ( RE_TRAILING , '' ) ; const cwd = process . cwd ( ) ; const parts = pkgpath . split ( path . sep ) ; const len = parts . length ; let idx = 1 ; // Handle packages nested under root if ( ! pkgpath . includes ( 'node_modules' ) && cwd != pkgpath ) { // Increase by distance from root idx += path . relative ( cwd , pkgpath ) . split ( path . sep ) . length ; // Handle scoped node_modules } else if ( parts [ len - 2 ] . charAt ( 0 ) == '@' ) { idx = 2 ; } return parts . slice ( len - idx ) . join ( path . sep ) ; }
Resolve package name from 'pkgpath'
@param {String} pkgpath
@returns {String}
Resolve package name from pkgpath