index.js
function loadFromFileOrHttp (fileOrUrlOrData) {
  // If this is not a string,
  // it is probably already the raw data.
  if (typeof fileOrUrlOrData !== 'string') {
    return Q(fileOrUrlOrData)
  }
  // otherwise load data from url or file
  if (fileOrUrlOrData.match(/^https?:\/\//)) {
    // Use the "request" package to download data
    return httpGet(fileOrUrlOrData, {
      redirect: true,
      headers: {
        'User-Agent': 'Bootprint/' + require('./package').version
      }
    }).then(function (result) {
      if (result.status !== 200) {
        var error = new Error('HTTP request failed with code ' + result.status)
        error.result = result
        throw error
      }
      return yaml.safeLoad(result.data, {json: true})
    }, function (error) {
      if (error.status) {
        throw new Error('Got ' + error.status + ' ' + error.data + ' when requesting ' + error.url, 'E_HTTP')
      } else {
        throw error
      }
    })
  } else {
    return Q.nfcall(fs.readFile, fileOrUrlOrData, 'utf8').then(function (data) {
      return yaml.safeLoad(data, {json: true})
    })
  }
}
function loadFromFileOrHttp (fileOrUrlOrData) {
  // If this is not a string,
  // it is probably already the raw data.
  if (typeof fileOrUrlOrData !== 'string') {
    return Q(fileOrUrlOrData)
  }
  // otherwise load data from url or file
  if (fileOrUrlOrData.match(/^https?:\/\//)) {
    // Use the "request" package to download data
    return httpGet(fileOrUrlOrData, {
      redirect: true,
      headers: {
        'User-Agent': 'Bootprint/' + require('./package').version
      }
    }).then(function (result) {
      if (result.status !== 200) {
        var error = new Error('HTTP request failed with code ' + result.status)
        error.result = result
        throw error
      }
      return yaml.safeLoad(result.data, {json: true})
    }, function (error) {
      if (error.status) {
        throw new Error('Got ' + error.status + ' ' + error.data + ' when requesting ' + error.url, 'E_HTTP')
      } else {
        throw error
      }
    })
  } else {
    return Q.nfcall(fs.readFile, fileOrUrlOrData, 'utf8').then(function (data) {
      return yaml.safeLoad(data, {json: true})
    })
  }
}
function loadFromFileOrHttp ( fileOrUrlOrData ) { // If this is not a string, // it is probably already the raw data. if ( typeof fileOrUrlOrData !== 'string' ) { return Q ( fileOrUrlOrData ) } // otherwise load data from url or file if ( fileOrUrlOrData . match ( / ^https?:\/\/ / ) ) { // Use the "request" package to download data return httpGet ( fileOrUrlOrData , { redirect : true , headers : { 'User-Agent' : 'Bootprint/' + require ( './package' ) . version } } ) . then ( function ( result ) { if ( result . status !== 200 ) { var error = new Error ( 'HTTP request failed with code ' + result . status ) error . result = result throw error } return yaml . safeLoad ( result . data , { json : true } ) } , function ( error ) { if ( error . status ) { throw new Error ( 'Got ' + error . status + ' ' + error . data + ' when requesting ' + error . url , 'E_HTTP' ) } else { throw error } } ) } else { return Q . nfcall ( fs . readFile , fileOrUrlOrData , 'utf8' ) . then ( function ( data ) { return yaml . safeLoad ( data , { json : true } ) } ) } }
Helper method for loading the bootprint-data
@param fileOrUrlOrData
@returns {*}
@private
Helper method for loading the bootprint - data