build/compare-size.js
function compareSizes(task) {
  var compressors = task.options.compress,
    newsizes = helpers.sizes(task, compressors),
    files = Object.keys(newsizes),
    sizecache = defaultCache,
    cache = helpers.get_cache(sizecache),
    tips = cache[""].tips,
    labels = helpers.sorted_labels(cache);

  // Obtain the current branch and continue...
  helpers.git_status(function(err, status) {
    var prefixes = compressors ? [""].concat(Object.keys(compressors)) : [""],
      commonHeader = prefixes.map(
        (label, i) => (i === 0 && compressors ? "raw" : label)
      );

    const tableOptions = {
      align: prefixes.map(() => "r").concat("l"),
      // eslint-disable-next-line no-control-regex
      stringLength: s => s.replace(/\x1B\[\d+m/g, "").length // Return a string, uncolored (suitable for testing .length, etc).
    };

    if (err) {
      console.warn(err);
      status = {};
    }

    let rows = [];
    rows.push(commonHeader.concat("Sizes"));

    // Raw sizes
    files.forEach(function(key) {
      rows.push(prefixes.map(prefix => newsizes[key][prefix]).concat(key + ""));
    });

    console.log(table(rows, tableOptions));

    // Comparisons
    labels.forEach(function(label) {
      var oldsizes = cache[label];

      // Skip metadata key and empty cache entries
      if (label === "" || !cache[label]) {
        return;
      }

      rows = [];

      // Header
      rows.push(
        commonHeader.concat("Compared to " + helpers.label(label, tips[label]))
      );

      // Data
      files.forEach(function(key) {
        var old = oldsizes && oldsizes[key];
        rows.push(
          prefixes
            .map(function(prefix) {
              return helpers.delta(old && newsizes[key][prefix] - old[prefix]);
            })
            .concat(key + "")
        );
      });

      console.log();
      console.log(table(rows, tableOptions));
    });

    // Update "last run" sizes
    cache[lastrun] = newsizes;

    // Remember if we're at a branch tip and the branch name is an available key
    if (
      status.branch &&
      !status.changed &&
      (status.branch in tips || !cache[status.branch])
    ) {
      tips[status.branch] = status.head;
      cache[status.branch] = newsizes;
      console.log("\nSaved as: " + status.branch);
    }

    // Write to file
    file.write(sizecache, JSON.stringify(cache));
  });
}
function compareSizes(task) {
  var compressors = task.options.compress,
    newsizes = helpers.sizes(task, compressors),
    files = Object.keys(newsizes),
    sizecache = defaultCache,
    cache = helpers.get_cache(sizecache),
    tips = cache[""].tips,
    labels = helpers.sorted_labels(cache);

  // Obtain the current branch and continue...
  helpers.git_status(function(err, status) {
    var prefixes = compressors ? [""].concat(Object.keys(compressors)) : [""],
      commonHeader = prefixes.map(
        (label, i) => (i === 0 && compressors ? "raw" : label)
      );

    const tableOptions = {
      align: prefixes.map(() => "r").concat("l"),
      // eslint-disable-next-line no-control-regex
      stringLength: s => s.replace(/\x1B\[\d+m/g, "").length // Return a string, uncolored (suitable for testing .length, etc).
    };

    if (err) {
      console.warn(err);
      status = {};
    }

    let rows = [];
    rows.push(commonHeader.concat("Sizes"));

    // Raw sizes
    files.forEach(function(key) {
      rows.push(prefixes.map(prefix => newsizes[key][prefix]).concat(key + ""));
    });

    console.log(table(rows, tableOptions));

    // Comparisons
    labels.forEach(function(label) {
      var oldsizes = cache[label];

      // Skip metadata key and empty cache entries
      if (label === "" || !cache[label]) {
        return;
      }

      rows = [];

      // Header
      rows.push(
        commonHeader.concat("Compared to " + helpers.label(label, tips[label]))
      );

      // Data
      files.forEach(function(key) {
        var old = oldsizes && oldsizes[key];
        rows.push(
          prefixes
            .map(function(prefix) {
              return helpers.delta(old && newsizes[key][prefix] - old[prefix]);
            })
            .concat(key + "")
        );
      });

      console.log();
      console.log(table(rows, tableOptions));
    });

    // Update "last run" sizes
    cache[lastrun] = newsizes;

    // Remember if we're at a branch tip and the branch name is an available key
    if (
      status.branch &&
      !status.changed &&
      (status.branch in tips || !cache[status.branch])
    ) {
      tips[status.branch] = status.head;
      cache[status.branch] = newsizes;
      console.log("\nSaved as: " + status.branch);
    }

    // Write to file
    file.write(sizecache, JSON.stringify(cache));
  });
}
function compareSizes ( task ) { var compressors = task . options . compress , newsizes = helpers . sizes ( task , compressors ) , files = Object . keys ( newsizes ) , sizecache = defaultCache , cache = helpers . get_cache ( sizecache ) , tips = cache [ "" ] . tips , labels = helpers . sorted_labels ( cache ) ; // Obtain the current branch and continue...
 helpers . git_status ( function ( err , status ) { var prefixes = compressors ? [ "" ] . concat ( Object . keys ( compressors ) ) : [ "" ] , commonHeader = prefixes . map ( ( label , i ) => ( i === 0 && compressors ? "raw" : label ) ) ; const tableOptions = { align : prefixes . map ( ( ) => "r" ) . concat ( "l" ) , // eslint-disable-next-line no-control-regex
 stringLength : s => s . replace ( / \x1B\[\d+m / g , "" ) . length // Return a string, uncolored (suitable for testing .length, etc).
 } ; if ( err ) { console . warn ( err ) ; status = { } ; } let rows = [ ] ; rows . push ( commonHeader . concat ( "Sizes" ) ) ; // Raw sizes
 files . forEach ( function ( key ) { rows . push ( prefixes . map ( prefix => newsizes [ key ] [ prefix ] ) . concat ( key + "" ) ) ; } ) ; console . log ( table ( rows , tableOptions ) ) ; // Comparisons
 labels . forEach ( function ( label ) { var oldsizes = cache [ label ] ; // Skip metadata key and empty cache entries
 if ( label === "" || ! cache [ label ] ) { return ; } rows = [ ] ; // Header
 rows . push ( commonHeader . concat ( "Compared to " + helpers . label ( label , tips [ label ] ) ) ) ; // Data
 files . forEach ( function ( key ) { var old = oldsizes && oldsizes [ key ] ; rows . push ( prefixes . map ( function ( prefix ) { return helpers . delta ( old && newsizes [ key ] [ prefix ] - old [ prefix ] ) ; } ) . concat ( key + "" ) ) ; } ) ; console . log ( ) ; console . log ( table ( rows , tableOptions ) ) ; } ) ; // Update "last run" sizes
 cache [ lastrun ] = newsizes ; // Remember if we're at a branch tip and the branch name is an available key
 if ( status . branch && ! status . changed && ( status . branch in tips || ! cache [ status . branch ] ) ) { tips [ status . branch ] = status . head ; cache [ status . branch ] = newsizes ; console . log ( "\nSaved as: " + status . branch ) ; } // Write to file
 file . write ( sizecache , JSON . stringify ( cache ) ) ; } ) ; }
Compare size to saved sizes Derived and adapted from Corey Frang's original `sizer`
Compare size to saved sizes Derived and adapted from Corey Frang s original sizer