function add (outputFile, timeout) {
    var failTimeout = timeout;
    var timer;

    if (!this.isStarted()) {
      throw new Error("MUST call `start` before `add`");
    }

    if (!this._exists(outputFile)) {
      // make sure we evaluate after the child process
      failTimeout = parseInt(timeout, 10) + parseInt(this.padTimeout, 10);
      // Stagger and grow the failure timeout padding, add 1s every 10 processes
      this.padTimeout += 100;

      // setup a timeout handler to detect failure
      timer = setTimeout(this.csFactory(function (done) {
        var self = this;

        // if the output file has not already been removed
        if (self._exists(outputFile)) {
          pathExists(outputFile)
            .then(function (fsExists) {
              var callback = self.callback;

              try {
                if (!fsExists) {
                  self._setError(new Error(
                    "'" + outputFile + "' did not get a snapshot before timeout"
                  ));
                }
                self._remove(outputFile, fsExists);

                if (self._isDone()) {
                  self._closeWatcher();
                  if (self.callback) {
                    self.callback = null;
                    setImmediate(function () {
                      callback(self.getError(), self.filesDone);
                    });
                  }
                }
              } catch (e) {
                console.error(e);
              }
              done();
            });
        } else {
          done();
        }
      }.bind(this), L_WAIT), parseInt(failTimeout, 10));

      // add the file tracking object
      this.files[outputFile] = {
        timer: timer
      };
    }
  }
function add (outputFile, timeout) {
    var failTimeout = timeout;
    var timer;

    if (!this.isStarted()) {
      throw new Error("MUST call `start` before `add`");
    }

    if (!this._exists(outputFile)) {
      
      failTimeout = parseInt(timeout, 10) + parseInt(this.padTimeout, 10);
      
      this.padTimeout += 100;

      
      timer = setTimeout(this.csFactory(function (done) {
        var self = this;

        
        if (self._exists(outputFile)) {
          pathExists(outputFile)
            .then(function (fsExists) {
              var callback = self.callback;

              try {
                if (!fsExists) {
                  self._setError(new Error(
                    "'" + outputFile + "' did not get a snapshot before timeout"
                  ));
                }
                self._remove(outputFile, fsExists);

                if (self._isDone()) {
                  self._closeWatcher();
                  if (self.callback) {
                    self.callback = null;
                    setImmediate(function () {
                      callback(self.getError(), self.filesDone);
                    });
                  }
                }
              } catch (e) {
                console.error(e);
              }
              done();
            });
        } else {
          done();
        }
      }.bind(this), L_WAIT), parseInt(failTimeout, 10));

      
      this.files[outputFile] = {
        timer: timer
      };
    }
  }
function add ( outputFile , timeout ) { var failTimeout = timeout ; var timer ; if ( ! this . isStarted ( ) ) { throw new Error ( "MUST call `start` before `add`" ) ; } if ( ! this . _exists ( outputFile ) ) { // make sure we evaluate after the child process failTimeout = parseInt ( timeout , 10 ) + parseInt ( this . padTimeout , 10 ) ; // Stagger and grow the failure timeout padding, add 1s every 10 processes this . padTimeout += 100 ; // setup a timeout handler to detect failure timer = setTimeout ( this . csFactory ( function ( done ) { var self = this ; // if the output file has not already been removed if ( self . _exists ( outputFile ) ) { pathExists ( outputFile ) . then ( function ( fsExists ) { var callback = self . callback ; try { if ( ! fsExists ) { self . _setError ( new Error ( "'" + outputFile + "' did not get a snapshot before timeout" ) ) ; } self . _remove ( outputFile , fsExists ) ; if ( self . _isDone ( ) ) { self . _closeWatcher ( ) ; if ( self . callback ) { self . callback = null ; setImmediate ( function ( ) { callback ( self . getError ( ) , self . filesDone ) ; } ) ; } } } catch ( e ) { console . error ( e ) ; } done ( ) ; } ) ; } else { done ( ) ; } } . bind ( this ) , L_WAIT ) , parseInt ( failTimeout , 10 ) ) ; // add the file tracking object this . files [ outputFile ] = { timer : timer } ; } }
Add a file to the files array if it's not there.

@param {String} outputFile - The full path to the output file to add.
@param {Number} timeout - timeout milliseconds to wait (max).
Add a file to the files array if it s not there .