index.js
function moduleIfString (pathOrObject, type) {
  // If this is a string, treat if as module to be required
  try {
    if (_.isString(pathOrObject)) {
      // Attempt to find module without resolving the contents
      // If there is an error, the module does not exist (which
      // is ignored at the moment)
      // If there is no error, the module should be loaded and error while loading
      // the module should be reported
      require.resolve(path.resolve(pathOrObject))
    }
  } catch (e) {
    debug('Ignoring missing ' + type + ' module: ' + pathOrObject)
    pathOrObject = undefined
  }

  // Require module if needed
  if (_.isString(pathOrObject)) {
    var absPath = path.resolve(pathOrObject)
    delete require.cache[absPath]
    pathOrObject = require(absPath)
  }
  return pathOrObject
}
function moduleIfString (pathOrObject, type) {
  // If this is a string, treat if as module to be required
  try {
    if (_.isString(pathOrObject)) {
      // Attempt to find module without resolving the contents
      // If there is an error, the module does not exist (which
      // is ignored at the moment)
      // If there is no error, the module should be loaded and error while loading
      // the module should be reported
      require.resolve(path.resolve(pathOrObject))
    }
  } catch (e) {
    debug('Ignoring missing ' + type + ' module: ' + pathOrObject)
    pathOrObject = undefined
  }

  // Require module if needed
  if (_.isString(pathOrObject)) {
    var absPath = path.resolve(pathOrObject)
    delete require.cache[absPath]
    pathOrObject = require(absPath)
  }
  return pathOrObject
}
function moduleIfString ( pathOrObject , type ) { // If this is a string, treat if as module to be required try { if ( _ . isString ( pathOrObject ) ) { // Attempt to find module without resolving the contents // If there is an error, the module does not exist (which // is ignored at the moment) // If there is no error, the module should be loaded and error while loading // the module should be reported require . resolve ( path . resolve ( pathOrObject ) ) } } catch ( e ) { debug ( 'Ignoring missing ' + type + ' module: ' + pathOrObject ) pathOrObject = undefined } // Require module if needed if ( _ . isString ( pathOrObject ) ) { var absPath = path . resolve ( pathOrObject ) delete require . cache [ absPath ] pathOrObject = require ( absPath ) } return pathOrObject }
Internal function that returns `require`s a module if the parameter is a string.

If parameter is a string (path) and a file with that path exists, load it as module
If the parameter is not a string, just return it.
If the parameter is a string, but the file does not exist, return `undefined`


@param {string|*} pathOrObject path to the file or configuration
@param {string} type additional information that can displayed in case the module is not found.
@returns {*}
@access private
Internal function that returns require s a module if the parameter is a string .