All files List.js

89.47% Statements 17/19
66.67% Branches 4/6
100% Functions 4/4
88.89% Lines 16/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 371x 1x       2x 2x 2x 2x 2x   2x     2x 2x 1x 1x 1x 4x                       1x       1x  
var Api = require('./Api')
var async = require('async')
 
class List {
  constructor(opts, config, logger) {
    this.opts = opts
    this.logger = logger
    this.api = new Api(config)
    Eif (opts.json == null) {
      opts.json = false
    }
    this.jsonOut = opts.json
  }
  run(cb) {
    this.api.getDumps((err, dumps) => {
      if (err) return cb(err)
      let shouldShowCompletedMesssage = true
      Eif (!this.jsonOut) {
        dumps.map((dump) => {
          this.logger.info(`- Dump ID: [ ${dump.dumpId} ]
Sequence: [ ${dump.sequence} ]
Account ID: [ ${dump.accountId} ]
Number of Files: [ ${dump.numFiles} ]
Finished: [ ${dump.finished} ]
Expires At: [ ${dump.expires} ]
Created At: [ ${dump.createdAt} ]`)
        })
      } else {
        this.logger.info(JSON.stringify(dumps))
        shouldShowCompletedMesssage = false
      }
      cb(null, shouldShowCompletedMesssage)
    })
  }
}
module.exports = List