src/transport.js
function loadModule( state, resourcePath ) {
	try {
		var key = path.resolve( resourcePath );
		delete require.cache[ key ];
		var modFn = require( resourcePath );
		var args = getArguments( modFn );
		args.shift();
		if ( args.length ) {
			return state.fount.resolve( args )
				.then( function( deps ) {
					var argList = _.map( args, function( arg ) {
						return deps[ arg ];
					} );
					argList.unshift( state.host );
					var mod = modFn.apply( modFn, argList );
					attachPath( state, mod, resourcePath );
					return mod;
				} );
		} else {
			var mod = modFn( state.host );
			attachPath( state, mod, resourcePath );
			return when( mod );
		}
	} catch ( err ) {
		console.error( 'Error loading resource module at %s with: %s', resourcePath, err.stack );
		return when( [] );
	}
}
function loadModule( state, resourcePath ) {
	try {
		var key = path.resolve( resourcePath );
		delete require.cache[ key ];
		var modFn = require( resourcePath );
		var args = getArguments( modFn );
		args.shift();
		if ( args.length ) {
			return state.fount.resolve( args )
				.then( function( deps ) {
					var argList = _.map( args, function( arg ) {
						return deps[ arg ];
					} );
					argList.unshift( state.host );
					var mod = modFn.apply( modFn, argList );
					attachPath( state, mod, resourcePath );
					return mod;
				} );
		} else {
			var mod = modFn( state.host );
			attachPath( state, mod, resourcePath );
			return when( mod );
		}
	} catch ( err ) {
		console.error( 'Error loading resource module at %s with: %s', resourcePath, err.stack );
		return when( [] );
	}
}
function loadModule ( state , resourcePath ) { try { var key = path . resolve ( resourcePath ) ; delete require . cache [ key ] ; var modFn = require ( resourcePath ) ; var args = getArguments ( modFn ) ; args . shift ( ) ; if ( args . length ) { return state . fount . resolve ( args ) . then ( function ( deps ) { var argList = _ . map ( args , function ( arg ) { return deps [ arg ] ; } ) ; argList . unshift ( state . host ) ; var mod = modFn . apply ( modFn , argList ) ; attachPath ( state , mod , resourcePath ) ; return mod ; } ) ; } else { var mod = modFn ( state . host ) ; attachPath ( state , mod , resourcePath ) ; return when ( mod ) ; } } catch ( err ) { console . error ( 'Error loading resource module at %s with: %s' , resourcePath , err . stack ) ; return when ( [ ] ) ; } }
loads a module based on the file path and resolves the function promises and all
loads a module based on the file path and resolves the function promises and all