packages/crafty-runner-webpack/src/webpack_output.js
function sortFiles(files) {
  const modules = [];
  const assets = [];

  let isAssets = false;

  for (var i in files) {
    const row = files[i];
    if (row[0] == "size" && row[2] == "asset") {
      isAssets = true;
    }

    if (row[0] == "size" || row[0] == "") {
      continue;
    }

    if (isAssets) {
      assets.push(row);
    } else {
      modules.push(row);
    }
  }

  const final = [];

  if (modules.length) {
    final.push(["size", "name", "module", "status"]);
    final.push(...modules.sort((a, b) => a[1] - b[1]));
  }

  if (modules.length && assets.length) {
    final.push(["", "", "", ""]);
  }

  if (assets.length) {
    final.push(["size", "name", "asset", "status"]);
    final.push(
      ...assets.sort((a, b) => {
        if (a[2] < b[2]) return -1;
        if (a[2] > b[2]) return 1;
        return 0;
      })
    );
  }

  // Replacing the file sizes in output log
  // to have predictable snapshot output
  // when testing Crafty. As webpack seems
  // to create differences in various environments
  // without differences in the actual output's size
  if (process.env.TESTING_CRAFTY) {
    return final.map(item => {
      if (item[0] != "" && item[0] != "size") {
        item[0] = 1000;
      }

      return item;
    });
  }

  return final;
}
function sortFiles(files) {
  const modules = [];
  const assets = [];

  let isAssets = false;

  for (var i in files) {
    const row = files[i];
    if (row[0] == "size" && row[2] == "asset") {
      isAssets = true;
    }

    if (row[0] == "size" || row[0] == "") {
      continue;
    }

    if (isAssets) {
      assets.push(row);
    } else {
      modules.push(row);
    }
  }

  const final = [];

  if (modules.length) {
    final.push(["size", "name", "module", "status"]);
    final.push(...modules.sort((a, b) => a[1] - b[1]));
  }

  if (modules.length && assets.length) {
    final.push(["", "", "", ""]);
  }

  if (assets.length) {
    final.push(["size", "name", "asset", "status"]);
    final.push(
      ...assets.sort((a, b) => {
        if (a[2] < b[2]) return -1;
        if (a[2] > b[2]) return 1;
        return 0;
      })
    );
  }

  // Replacing the file sizes in output log
  // to have predictable snapshot output
  // when testing Crafty. As webpack seems
  // to create differences in various environments
  // without differences in the actual output's size
  if (process.env.TESTING_CRAFTY) {
    return final.map(item => {
      if (item[0] != "" && item[0] != "size") {
        item[0] = 1000;
      }

      return item;
    });
  }

  return final;
}
function sortFiles ( files ) { const modules = [ ] ; const assets = [ ] ; let isAssets = false ; for ( var i in files ) { const row = files [ i ] ; if ( row [ 0 ] == "size" && row [ 2 ] == "asset" ) { isAssets = true ; } if ( row [ 0 ] == "size" || row [ 0 ] == "" ) { continue ; } if ( isAssets ) { assets . push ( row ) ; } else { modules . push ( row ) ; } } const final = [ ] ; if ( modules . length ) { final . push ( [ "size" , "name" , "module" , "status" ] ) ; final . push ( ... modules . sort ( ( a , b ) => a [ 1 ] - b [ 1 ] ) ) ; } if ( modules . length && assets . length ) { final . push ( [ "" , "" , "" , "" ] ) ; } if ( assets . length ) { final . push ( [ "size" , "name" , "asset" , "status" ] ) ; final . push ( ... assets . sort ( ( a , b ) => { if ( a [ 2 ] < b [ 2 ] ) return - 1 ; if ( a [ 2 ] > b [ 2 ] ) return 1 ; return 0 ; } ) ) ; } // Replacing the file sizes in output log // to have predictable snapshot output // when testing Crafty. As webpack seems // to create differences in various environments // without differences in the actual output's size if ( process . env . TESTING_CRAFTY ) { return final . map ( item => { if ( item [ 0 ] != "" && item [ 0 ] != "size" ) { item [ 0 ] = 1000 ; } return item ; } ) ; } return final ; }
Sort the files order.
The main reason is that test snapshots need the order to stay the same.
For some reason this isn't the case sometimes.

@param {*} files
Sort the files order . The main reason is that test snapshots need the order to stay the same . For some reason this isn t the case sometimes .