npm-crawl.js
function(context, parentPkg, childPkg, isRoot){
		var pkg = parentPkg;
		var isFlat = context.isFlatFileStructure;

		// if a peer dependency, and not isRoot
		if(childPkg._isPeerDependency && !isRoot ) {
			// check one node_module level higher
			childPkg.origFileUrl = nodeModuleAddress(pkg.fileUrl)+"/"+childPkg.name+"/package.json";
		} else if(isRoot) {
			childPkg.origFileUrl = utils.path.depPackage(pkg.fileUrl, childPkg.name);
		} else {
			// npm 2
			childPkg.origFileUrl = childPkg.nestedFileUrl =
				utils.path.depPackage(pkg.fileUrl, childPkg.name);

			if(isFlat) {
				// npm 3
				childPkg.origFileUrl = crawl.parentMostAddress(context,
															   childPkg);
			}
		}

		// check if childPkg matches a parent's version ... if it
		// does ... do nothing
		if(crawl.hasParentPackageThatMatches(context, childPkg)) {
			return;
		}

		if(crawl.isSameRequestedVersionFound(context, childPkg)) {
			return;
		}

		var requestedVersion = childPkg.version;
		return npmLoad(context, childPkg, requestedVersion)
		.then(function(pkg){
			crawl.setVersionsConfig(context, pkg, requestedVersion);
			return pkg;
		});
	}
function(context, parentPkg, childPkg, isRoot){
		var pkg = parentPkg;
		var isFlat = context.isFlatFileStructure;

		// if a peer dependency, and not isRoot
		if(childPkg._isPeerDependency && !isRoot ) {
			// check one node_module level higher
			childPkg.origFileUrl = nodeModuleAddress(pkg.fileUrl)+"/"+childPkg.name+"/package.json";
		} else if(isRoot) {
			childPkg.origFileUrl = utils.path.depPackage(pkg.fileUrl, childPkg.name);
		} else {
			// npm 2
			childPkg.origFileUrl = childPkg.nestedFileUrl =
				utils.path.depPackage(pkg.fileUrl, childPkg.name);

			if(isFlat) {
				// npm 3
				childPkg.origFileUrl = crawl.parentMostAddress(context,
															   childPkg);
			}
		}

		// check if childPkg matches a parent's version ... if it
		// does ... do nothing
		if(crawl.hasParentPackageThatMatches(context, childPkg)) {
			return;
		}

		if(crawl.isSameRequestedVersionFound(context, childPkg)) {
			return;
		}

		var requestedVersion = childPkg.version;
		return npmLoad(context, childPkg, requestedVersion)
		.then(function(pkg){
			crawl.setVersionsConfig(context, pkg, requestedVersion);
			return pkg;
		});
	}
function ( context , parentPkg , childPkg , isRoot ) { var pkg = parentPkg ; var isFlat = context . isFlatFileStructure ; // if a peer dependency, and not isRoot if ( childPkg . _isPeerDependency && ! isRoot ) { // check one node_module level higher childPkg . origFileUrl = nodeModuleAddress ( pkg . fileUrl ) + "/" + childPkg . name + "/package.json" ; } else if ( isRoot ) { childPkg . origFileUrl = utils . path . depPackage ( pkg . fileUrl , childPkg . name ) ; } else { // npm 2 childPkg . origFileUrl = childPkg . nestedFileUrl = utils . path . depPackage ( pkg . fileUrl , childPkg . name ) ; if ( isFlat ) { // npm 3 childPkg . origFileUrl = crawl . parentMostAddress ( context , childPkg ) ; } } // check if childPkg matches a parent's version ... if it // does ... do nothing if ( crawl . hasParentPackageThatMatches ( context , childPkg ) ) { return ; } if ( crawl . isSameRequestedVersionFound ( context , childPkg ) ) { return ; } var requestedVersion = childPkg . version ; return npmLoad ( context , childPkg , requestedVersion ) . then ( function ( pkg ) { crawl . setVersionsConfig ( context , pkg , requestedVersion ) ; return pkg ; } ) ; }
Fetch a particular package.json dependency
@param {Object} context
@param {NpmPackage} parentPkg
@param {NpmPackage} childPkg
@param {Boolean} [isRoot] If the root module's dependencies shoudl be crawled.
@return {Promise} A promise when the package has loaded
Fetch a particular package . json dependency