resolve-opts.js
function normalize(val, basedir, pkg) {

    if (typeof val === 'string') {
      val = { path: val };
    }

    var originalPath = val.path;

    // npm3 treatment of sub-package paths starting with ./node_modules/
    var subPkgName = val.path.replace(/^\.\/node_modules\/([^/]+).*/,'$1');
    if (subPkgName != originalPath)  {
      var subPkg = resolvePkg({ path:subPkgName }, basedir, true);
      val.path = subPkg.dir + val.path.slice(15 + subPkgName.length);
    }
    // join with basedir if relative directory path
    else if (/^\.$|^\.\.$|^\.\/|^\.\.\//.test(val.path)) {
      val.path = fspath.join(basedir || opts.basedir, val.path);
    }

    // for brevity on console output
    val.inspect = function() {
      return (originalPath) +
             (pkg ? ' in ' + pkg : '') +
             (val.cache ?  ' (cached)' : '');
    };

    if (pkg) {
      val._pkg = pkg;
    }

    return val;
  }
function normalize(val, basedir, pkg) {

    if (typeof val === 'string') {
      val = { path: val };
    }

    var originalPath = val.path;

    // npm3 treatment of sub-package paths starting with ./node_modules/
    var subPkgName = val.path.replace(/^\.\/node_modules\/([^/]+).*/,'$1');
    if (subPkgName != originalPath)  {
      var subPkg = resolvePkg({ path:subPkgName }, basedir, true);
      val.path = subPkg.dir + val.path.slice(15 + subPkgName.length);
    }
    // join with basedir if relative directory path
    else if (/^\.$|^\.\.$|^\.\/|^\.\.\//.test(val.path)) {
      val.path = fspath.join(basedir || opts.basedir, val.path);
    }

    // for brevity on console output
    val.inspect = function() {
      return (originalPath) +
             (pkg ? ' in ' + pkg : '') +
             (val.cache ?  ' (cached)' : '');
    };

    if (pkg) {
      val._pkg = pkg;
    }

    return val;
  }
function normalize ( val , basedir , pkg ) { if ( typeof val === 'string' ) { val = { path : val } ; } var originalPath = val . path ; // npm3 treatment of sub-package paths starting with ./node_modules/ var subPkgName = val . path . replace ( / ^\.\/node_modules\/([^/]+).* / , '$1' ) ; if ( subPkgName != originalPath ) { var subPkg = resolvePkg ( { path : subPkgName } , basedir , true ) ; val . path = subPkg . dir + val . path . slice ( 15 + subPkgName . length ) ; } // join with basedir if relative directory path else if ( / ^\.$|^\.\.$|^\.\/|^\.\.\/ / . test ( val . path ) ) { val . path = fspath . join ( basedir || opts . basedir , val . path ) ; } // for brevity on console output val . inspect = function ( ) { return ( originalPath ) + ( pkg ? ' in ' + pkg : '' ) + ( val . cache ? ' (cached)' : '' ) ; } ; if ( pkg ) { val . _pkg = pkg ; } return val ; }
normalize a single opts key value
normalize a single opts key value