lib/html-snapshots.js
function (options, listener) {
    var inputGenerator, notifier, started, result, q, emitter, completion;

    options = options || {};
    prepOptions(options);

    // create the inputGenerator, default to robots
    inputGenerator = inputFactory.create(options.input);

    // clean the snapshot output directory
    if (options.outputDirClean) {
      rimraf(options.outputDir);
    }

    // start async completion notification.
    notifier = new Notifier();
    emitter = new EventEmitter();
    started = notifier.start(options.pollInterval, inputGenerator,
      function (err, completed) {
        emitter.emit("complete", err, completed);
      });

    if (started) {
      // create the completion Promise.
      completion = new Promise(function (resolve, reject) {
        function completionResolver (err, completed) {
          try {
            _.isFunction(listener) && listener(err, completed);
          } catch (e) {
            console.error("User supplied listener exception", e);
          }
          if (err) {
            err.notCompleted = notifier.filesNotDone;
            err.completed = completed;
            reject(err);
          } else {
            resolve(completed);
          }
        }
        emitter.addListener("complete", completionResolver);
      });

      // create a worker queue with a parallel process limit.
      q = asyncLib.queue(function (task, callback) {
        task(_.once(callback));
      }, options.processLimit);

      // have the queue call notifier.empty when last item
      //  from the queue is given to a worker.
      q.empty = notifier.qEmpty.bind(notifier);

      // expose abort callback to input generators via options.
      options._abort = function (err) {
        notifier.abort(q, err);
      };

      // generate input for the snapshots.
      result = inputGenerator.run(options, function (input) {
        // give the worker the input and place into the queue
        q.push(_.partial(worker, input, options, notifier));
      })
        // after input generation, resolve on browser completion.
        .then(function () {
          return completion;
        });
    } else {
      result = Promise.reject("failed to start async notifier");
    }

    return result;
  }
function (options, listener) {
    var inputGenerator, notifier, started, result, q, emitter, completion;

    options = options || {};
    prepOptions(options);

    // create the inputGenerator, default to robots
    inputGenerator = inputFactory.create(options.input);

    // clean the snapshot output directory
    if (options.outputDirClean) {
      rimraf(options.outputDir);
    }

    // start async completion notification.
    notifier = new Notifier();
    emitter = new EventEmitter();
    started = notifier.start(options.pollInterval, inputGenerator,
      function (err, completed) {
        emitter.emit("complete", err, completed);
      });

    if (started) {
      // create the completion Promise.
      completion = new Promise(function (resolve, reject) {
        function completionResolver (err, completed) {
          try {
            _.isFunction(listener) && listener(err, completed);
          } catch (e) {
            console.error("User supplied listener exception", e);
          }
          if (err) {
            err.notCompleted = notifier.filesNotDone;
            err.completed = completed;
            reject(err);
          } else {
            resolve(completed);
          }
        }
        emitter.addListener("complete", completionResolver);
      });

      // create a worker queue with a parallel process limit.
      q = asyncLib.queue(function (task, callback) {
        task(_.once(callback));
      }, options.processLimit);

      // have the queue call notifier.empty when last item
      //  from the queue is given to a worker.
      q.empty = notifier.qEmpty.bind(notifier);

      // expose abort callback to input generators via options.
      options._abort = function (err) {
        notifier.abort(q, err);
      };

      // generate input for the snapshots.
      result = inputGenerator.run(options, function (input) {
        // give the worker the input and place into the queue
        q.push(_.partial(worker, input, options, notifier));
      })
        // after input generation, resolve on browser completion.
        .then(function () {
          return completion;
        });
    } else {
      result = Promise.reject("failed to start async notifier");
    }

    return result;
  }
function ( options , listener ) { var inputGenerator , notifier , started , result , q , emitter , completion ; options = options || { } ; prepOptions ( options ) ; // create the inputGenerator, default to robots inputGenerator = inputFactory . create ( options . input ) ; // clean the snapshot output directory if ( options . outputDirClean ) { rimraf ( options . outputDir ) ; } // start async completion notification. notifier = new Notifier ( ) ; emitter = new EventEmitter ( ) ; started = notifier . start ( options . pollInterval , inputGenerator , function ( err , completed ) { emitter . emit ( "complete" , err , completed ) ; } ) ; if ( started ) { // create the completion Promise. completion = new Promise ( function ( resolve , reject ) { function completionResolver ( err , completed ) { try { _ . isFunction ( listener ) && listener ( err , completed ) ; } catch ( e ) { console . error ( "User supplied listener exception" , e ) ; } if ( err ) { err . notCompleted = notifier . filesNotDone ; err . completed = completed ; reject ( err ) ; } else { resolve ( completed ) ; } } emitter . addListener ( "complete" , completionResolver ) ; } ) ; // create a worker queue with a parallel process limit. q = asyncLib . queue ( function ( task , callback ) { task ( _ . once ( callback ) ) ; } , options . processLimit ) ; // have the queue call notifier.empty when last item //  from the queue is given to a worker. q . empty = notifier . qEmpty . bind ( notifier ) ; // expose abort callback to input generators via options. options . _abort = function ( err ) { notifier . abort ( q , err ) ; } ; // generate input for the snapshots. result = inputGenerator . run ( options , function ( input ) { // give the worker the input and place into the queue q . push ( _ . partial ( worker , input , options , notifier ) ) ; } ) // after input generation, resolve on browser completion. . then ( function ( ) { return completion ; } ) ; } else { result = Promise . reject ( "failed to start async notifier" ) ; } return result ; }
Run all the snapshots using the requested inputGenerator

@param {Object} options - ALL user supplied html snapshots options.
@param {String} options.outputDir - Directory to write the html files to.
@param {String} [options.input] - Input source type "robots", "sitemap", "array";
Defaults to "robots".
@param {Boolean} [options.outputDirClean] - True if output dir should be rm -rf;
Defaults to false.
@param {Number} [options.pollInterval] -
@param {Function} [listener] - User supplied optional callback.
@returns {Promise} Resolves on completion.
Run all the snapshots using the requested inputGenerator