All files / src/utils warnIfEmpty.js

0% Statements 0/1
71.43% Branches 5/7
100% Functions 0/0
0% Lines 0/1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                                   
import _ from 'underscore'
import warn from '../reporters/warn'
 
export default function warnIfEmpty (data, outPath, opts_) {
  if (!opts_ || (opts_ && opts_.verbose !== false)) {
    if (!data || _.isEmpty(data)) {
      let msg = 'You didn\'t pass any data to write for file: `' + outPath + '`. Writing out an empty '
      if (!data) {
        msg += 'file'
      } else if (_.isEmpty(data)) {
        msg += Array.isArray(data) === true ? 'array' : 'object'
      }
      msg += '...'
      warn(msg)
    }
  }
}