classes/BowerMap.js
function getCommonPathBase( paths ) {

		var list = [];
		var minLength = 999999999;

		var commonPath = "";

		//break up paths into parts
		paths.forEach( function( file ) {

			//normalize path seperators
			file = file.replace( pathSepRegExp, path.sep );

			//get resolved path parts for file directory
			if ( file.charAt(0) === path.sep ){
				file = file.substr(1);
			}
			//console.log("   "+file);
			//console.log("   "+path.dirname( file ));
			var dirname = path.dirname( file );
			var parts = dirname === "." ? [] : dirname.split( path.sep );
			list.push( parts );

			//save minimum path length for next step
			minLength = Math.min( minLength, parts.length );

		} );

		var listLength = list.length;

		grunt.verbose.writeln( JSON.stringify( list, undefined, "   ") );
		//check for common parts
		if ( listLength > 1 ) {
			var common = true;
			var index = -1;

			//iterate parts up to minLength
			for ( var i = 0; i < minLength; i++ ) {

				for ( var j = 1; j < listLength; j++ ) {
					if ( list[ j ][ i ] !== list[ j - 1 ][ i ] ) {
						common = false;
						break;
					}
				}

				if ( !common ) {
					index = i;
					break;
				}
			}
			//catch case where all paths are common
			if ( index < 0 ){
				index = minLength;
			}

			//build new paths array
			//for ( var n=0; n<listLength; n++ ) {
			//	newPaths.push( path.join( list[n].slice( index ) ) );
			//}

			commonPath = list[0].slice( 0, index ).join( path.sep );

		}
		else if ( listLength === 1 ) {
			commonPath = list[0].join( path.sep );
		}

		return commonPath;

	}
function getCommonPathBase( paths ) {

		var list = [];
		var minLength = 999999999;

		var commonPath = "";

		//break up paths into parts
		paths.forEach( function( file ) {

			//normalize path seperators
			file = file.replace( pathSepRegExp, path.sep );

			//get resolved path parts for file directory
			if ( file.charAt(0) === path.sep ){
				file = file.substr(1);
			}
			//console.log("   "+file);
			//console.log("   "+path.dirname( file ));
			var dirname = path.dirname( file );
			var parts = dirname === "." ? [] : dirname.split( path.sep );
			list.push( parts );

			//save minimum path length for next step
			minLength = Math.min( minLength, parts.length );

		} );

		var listLength = list.length;

		grunt.verbose.writeln( JSON.stringify( list, undefined, "   ") );
		//check for common parts
		if ( listLength > 1 ) {
			var common = true;
			var index = -1;

			//iterate parts up to minLength
			for ( var i = 0; i < minLength; i++ ) {

				for ( var j = 1; j < listLength; j++ ) {
					if ( list[ j ][ i ] !== list[ j - 1 ][ i ] ) {
						common = false;
						break;
					}
				}

				if ( !common ) {
					index = i;
					break;
				}
			}
			//catch case where all paths are common
			if ( index < 0 ){
				index = minLength;
			}

			//build new paths array
			//for ( var n=0; n<listLength; n++ ) {
			//	newPaths.push( path.join( list[n].slice( index ) ) );
			//}

			commonPath = list[0].slice( 0, index ).join( path.sep );

		}
		else if ( listLength === 1 ) {
			commonPath = list[0].join( path.sep );
		}

		return commonPath;

	}
function getCommonPathBase ( paths ) { var list = [ ] ; var minLength = 999999999 ; var commonPath = "" ; //break up paths into parts paths . forEach ( function ( file ) { //normalize path seperators file = file . replace ( pathSepRegExp , path . sep ) ; //get resolved path parts for file directory if ( file . charAt ( 0 ) === path . sep ) { file = file . substr ( 1 ) ; } //console.log("   "+file); //console.log("   "+path.dirname( file )); var dirname = path . dirname ( file ) ; var parts = dirname === "." ? [ ] : dirname . split ( path . sep ) ; list . push ( parts ) ; //save minimum path length for next step minLength = Math . min ( minLength , parts . length ) ; } ) ; var listLength = list . length ; grunt . verbose . writeln ( JSON . stringify ( list , undefined , "   " ) ) ; //check for common parts if ( listLength > 1 ) { var common = true ; var index = - 1 ; //iterate parts up to minLength for ( var i = 0 ; i < minLength ; i ++ ) { for ( var j = 1 ; j < listLength ; j ++ ) { if ( list [ j ] [ i ] !== list [ j - 1 ] [ i ] ) { common = false ; break ; } } if ( ! common ) { index = i ; break ; } } //catch case where all paths are common if ( index < 0 ) { index = minLength ; } //build new paths array //for ( var n=0; n<listLength; n++ ) { //	newPaths.push( path.join( list[n].slice( index ) ) ); //} commonPath = list [ 0 ] . slice ( 0 , index ) . join ( path . sep ) ; } else if ( listLength === 1 ) { commonPath = list [ 0 ] . join ( path . sep ) ; } return commonPath ; }
determines a shared base path among paths
@param paths {Array} of strings
@returns {String}
determines a shared base path among paths