lib/exec.js
function Executable(log, command) {
  /** @type {string} */
  this.command = command

  /** @type {Array.<function(Error, Buffer, Buffer)>} */
  this.callbacks = []

  /** @type {Arguments} */
  this.results = null

  var startTime = Date.now()
  child_process.exec(this.command, function() {
    var timeDiff = `${Date.now() - startTime}`
    if (timeDiff.length < 3) timeDiff = `   ${timeDiff}`.slice(-3)
    log.debug(`Exec | ${timeDiff}ms | ${this.command}`)
    this.results = arguments

    for (var i = 0; i < this.callbacks.length; i++) {
      var callback = this.callbacks[i]
      callback.apply(null, arguments)
    }
  }.bind(this))
}
function Executable(log, command) {
  /** @type {string} */
  this.command = command

  /** @type {Array.<function(Error, Buffer, Buffer)>} */
  this.callbacks = []

  /** @type {Arguments} */
  this.results = null

  var startTime = Date.now()
  child_process.exec(this.command, function() {
    var timeDiff = `${Date.now() - startTime}`
    if (timeDiff.length < 3) timeDiff = `   ${timeDiff}`.slice(-3)
    log.debug(`Exec | ${timeDiff}ms | ${this.command}`)
    this.results = arguments

    for (var i = 0; i < this.callbacks.length; i++) {
      var callback = this.callbacks[i]
      callback.apply(null, arguments)
    }
  }.bind(this))
}
function Executable ( log , command ) { /** @type {string} */ this . command = command /** @type {Array.<function(Error, Buffer, Buffer)>} */ this . callbacks = [ ] /** @type {Arguments} */ this . results = null var startTime = Date . now ( ) child_process . exec ( this . command , function ( ) { var timeDiff = ` ${ Date . now ( ) - startTime } ` if ( timeDiff . length < 3 ) timeDiff = ` ${ timeDiff } ` . slice ( - 3 ) log . debug ( ` ${ timeDiff } ${ this . command } ` ) this . results = arguments for ( var i = 0 ; i < this . callbacks . length ; i ++ ) { var callback = this . callbacks [ i ] callback . apply ( null , arguments ) } } . bind ( this ) ) }
A memoized executable command. The first time the command is run, the results are stored.
Callbacks are tracked while the command is running to avoid race conditions.

@constructor
@param {Log} log A logging instance.
@param {string} command The command to execute.
A memoized executable command . The first time the command is run the results are stored . Callbacks are tracked while the command is running to avoid race conditions .