lib/index.js
function getRefSchema (refVal, refType, parent, options, state) {
  const loader = getLoader(refType, options)
  if (refType && loader) {
    let newVal
    let oldBasePath
    let loaderValue
    let filePath
    let fullRefFilePath

    if (refType === 'file') {
      filePath = utils.getRefFilePath(refVal)
      fullRefFilePath = utils.isAbsolute(filePath) ? filePath : path.resolve(state.cwd, filePath)

      if (cache[fullRefFilePath]) {
        loaderValue = cache[fullRefFilePath]
      }
    }

    if (!loaderValue) {
      loaderValue = loader(refVal, options)
      if (loaderValue) {
        // adjust base folder if needed so that we can handle paths in nested folders
        if (refType === 'file') {
          let dirname = path.dirname(filePath)
          if (dirname === '.') {
            dirname = ''
          }

          if (dirname) {
            oldBasePath = state.cwd
            const newBasePath = path.resolve(state.cwd, dirname)
            options.baseFolder = state.cwd = newBasePath
          }
        }

        loaderValue = derefSchema(loaderValue, options, state)

        // reset
        if (oldBasePath) {
          options.baseFolder = state.cwd = oldBasePath
        }
      }
    }

    if (loaderValue) {
      if (refType === 'file' && fullRefFilePath && !cache[fullRefFilePath]) {
        cache[fullRefFilePath] = loaderValue
      }

      if (refVal.indexOf('#') >= 0) {
        const refPaths = refVal.split('#')
        const refPath = refPaths[1]
        const refNewVal = utils.getRefPathValue(loaderValue, refPath)
        if (refNewVal) {
          newVal = refNewVal
        }
      } else {
        newVal = loaderValue
      }
    }

    return newVal
  } else if (refType === 'local') {
    return utils.getRefPathValue(parent, refVal)
  }
}
function getRefSchema (refVal, refType, parent, options, state) {
  const loader = getLoader(refType, options)
  if (refType && loader) {
    let newVal
    let oldBasePath
    let loaderValue
    let filePath
    let fullRefFilePath

    if (refType === 'file') {
      filePath = utils.getRefFilePath(refVal)
      fullRefFilePath = utils.isAbsolute(filePath) ? filePath : path.resolve(state.cwd, filePath)

      if (cache[fullRefFilePath]) {
        loaderValue = cache[fullRefFilePath]
      }
    }

    if (!loaderValue) {
      loaderValue = loader(refVal, options)
      if (loaderValue) {
        // adjust base folder if needed so that we can handle paths in nested folders
        if (refType === 'file') {
          let dirname = path.dirname(filePath)
          if (dirname === '.') {
            dirname = ''
          }

          if (dirname) {
            oldBasePath = state.cwd
            const newBasePath = path.resolve(state.cwd, dirname)
            options.baseFolder = state.cwd = newBasePath
          }
        }

        loaderValue = derefSchema(loaderValue, options, state)

        // reset
        if (oldBasePath) {
          options.baseFolder = state.cwd = oldBasePath
        }
      }
    }

    if (loaderValue) {
      if (refType === 'file' && fullRefFilePath && !cache[fullRefFilePath]) {
        cache[fullRefFilePath] = loaderValue
      }

      if (refVal.indexOf('#') >= 0) {
        const refPaths = refVal.split('#')
        const refPath = refPaths[1]
        const refNewVal = utils.getRefPathValue(loaderValue, refPath)
        if (refNewVal) {
          newVal = refNewVal
        }
      } else {
        newVal = loaderValue
      }
    }

    return newVal
  } else if (refType === 'local') {
    return utils.getRefPathValue(parent, refVal)
  }
}
function getRefSchema ( refVal , refType , parent , options , state ) { const loader = getLoader ( refType , options ) if ( refType && loader ) { let newVal let oldBasePath let loaderValue let filePath let fullRefFilePath if ( refType === 'file' ) { filePath = utils . getRefFilePath ( refVal ) fullRefFilePath = utils . isAbsolute ( filePath ) ? filePath : path . resolve ( state . cwd , filePath ) if ( cache [ fullRefFilePath ] ) { loaderValue = cache [ fullRefFilePath ] } } if ( ! loaderValue ) { loaderValue = loader ( refVal , options ) if ( loaderValue ) { // adjust base folder if needed so that we can handle paths in nested folders if ( refType === 'file' ) { let dirname = path . dirname ( filePath ) if ( dirname === '.' ) { dirname = '' } if ( dirname ) { oldBasePath = state . cwd const newBasePath = path . resolve ( state . cwd , dirname ) options . baseFolder = state . cwd = newBasePath } } loaderValue = derefSchema ( loaderValue , options , state ) // reset if ( oldBasePath ) { options . baseFolder = state . cwd = oldBasePath } } } if ( loaderValue ) { if ( refType === 'file' && fullRefFilePath && ! cache [ fullRefFilePath ] ) { cache [ fullRefFilePath ] = loaderValue } if ( refVal . indexOf ( '#' ) >= 0 ) { const refPaths = refVal . split ( '#' ) const refPath = refPaths [ 1 ] const refNewVal = utils . getRefPathValue ( loaderValue , refPath ) if ( refNewVal ) { newVal = refNewVal } } else { newVal = loaderValue } } return newVal } else if ( refType === 'local' ) { return utils . getRefPathValue ( parent , refVal ) } }
Returns the reference schema that refVal points to.
If the ref val points to a ref within a file, the file is loaded and fully derefed, before we get the
pointing property. Derefed files are cached.

@param refVal
@param refType
@param parent
@param options
@param state
@private
Returns the reference schema that refVal points to . If the ref val points to a ref within a file the file is loaded and fully derefed before we get the pointing property . Derefed files are cached .