All files / src/helpers discernLoader.js

100% Statements 4/4
100% Branches 6/6
100% Functions 0/0
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14      346x 346x 346x 346x              
import discernFormat from './discernFormat'
import loaders from '../loaders/index'
 
export default function discernLoader (filePath, opts_ = {}) {
  var which = opts_.sync === true ? 'sync' : 'async'
  var format = discernFormat(filePath)
  var loader = loaders[which][format]
  // If we don't have a loader for this format, read in as a normal file
  if (typeof loader === 'undefined') {
    loader = loaders[which]['txt']
  }
  return loader
}