lib/internal/bower-utils.js
function resolve(name, workdir) {
	workdir = workdir || process.cwd();
	var compName = componentName(name),
		subname = name.substring(compName.length + 1),
		basedir = path.join(componentsHome(workdir), compName),
		bowerJson = require(path.join(basedir, 'bower.json'));

	var mainfile = Array.isArray(bowerJson.main) 
		? bowerJson.main.filter(function(file) { return /\.js$/.test(file); })[0] 
		: bowerJson.main;

	if (subname && subname.length > 0) {
		var subpath = mainfile && path.join(basedir, mainfile, '..', subname);
		if (subpath && (fs.existsSync(subpath) || fs.existsSync(subpath + '.js'))) {
			return path.join(basedir, mainfile, '..', subname);
		} else {
			return path.join(basedir, subname);
		}
	} else {
		if (mainfile) {
			return path.join(basedir, mainfile);
		}	else {
			if (fs.existsSync(path.join(basedir, "index.js"))) {
				return path.join(basedir, "index.js");
			} else {
				return path.join(basedir, compName);
			}
		}
	}
}
function resolve(name, workdir) {
	workdir = workdir || process.cwd();
	var compName = componentName(name),
		subname = name.substring(compName.length + 1),
		basedir = path.join(componentsHome(workdir), compName),
		bowerJson = require(path.join(basedir, 'bower.json'));

	var mainfile = Array.isArray(bowerJson.main) 
		? bowerJson.main.filter(function(file) { return /\.js$/.test(file); })[0] 
		: bowerJson.main;

	if (subname && subname.length > 0) {
		var subpath = mainfile && path.join(basedir, mainfile, '..', subname);
		if (subpath && (fs.existsSync(subpath) || fs.existsSync(subpath + '.js'))) {
			return path.join(basedir, mainfile, '..', subname);
		} else {
			return path.join(basedir, subname);
		}
	} else {
		if (mainfile) {
			return path.join(basedir, mainfile);
		}	else {
			if (fs.existsSync(path.join(basedir, "index.js"))) {
				return path.join(basedir, "index.js");
			} else {
				return path.join(basedir, compName);
			}
		}
	}
}
function resolve ( name , workdir ) { workdir = workdir || process . cwd ( ) ; var compName = componentName ( name ) , subname = name . substring ( compName . length + 1 ) , basedir = path . join ( componentsHome ( workdir ) , compName ) , bowerJson = require ( path . join ( basedir , 'bower.json' ) ) ; var mainfile = Array . isArray ( bowerJson . main ) ? bowerJson . main . filter ( function ( file ) { return / \.js$ / . test ( file ) ; } ) [ 0 ] : bowerJson . main ; if ( subname && subname . length > 0 ) { var subpath = mainfile && path . join ( basedir , mainfile , '..' , subname ) ; if ( subpath && ( fs . existsSync ( subpath ) || fs . existsSync ( subpath + '.js' ) ) ) { return path . join ( basedir , mainfile , '..' , subname ) ; } else { return path . join ( basedir , subname ) ; } } else { if ( mainfile ) { return path . join ( basedir , mainfile ) ; } else { if ( fs . existsSync ( path . join ( basedir , "index.js" ) ) ) { return path . join ( basedir , "index.js" ) ; } else { return path . join ( basedir , compName ) ; } } } }
resolve and return entry file's full path for specified component
resolve and return entry file s full path for specified component