function gatherBuildResources(percyClient, buildDirs, rootDirs) {
  const hashToResource = {};
  const paths = globby.sync(buildDirs, {absolute: true, nodir: true});

  let absolutePath, resourceUrl, content, sha;
  for (let i = 0; i < paths.length; i++) {
    absolutePath = paths[i];
    resourceUrl = absolutePath;
    rootDirs.forEach((rootDir) => {
      resourceUrl = resourceUrl.replace(rootDir, '');
    });
    if (resourceUrl.charAt(0) !== '/') resourceUrl = '/' + resourceUrl;
    // Skip large files.
    if (fs.statSync(absolutePath)['size'] > MAX_FILE_SIZE_BYTES) {
      console.warn('\n[percy][WARNING] Skipping large build resource: ',
          resourceUrl);
      continue;
    }

    content = fs.readFileSync(absolutePath);
    sha = crypto.createHash('sha256').update(content).digest('hex');

    hashToResource[sha] = percyClient.makeResource({
      resourceUrl: encodeURI(resourceUrl),
      sha: sha,
      localPath: absolutePath,
    });
  }

  return hashToResource;
}
/**
 * Reads the filesystem for assets and assembles an object to be handed to percy
 * so it can upload the assets.
 * Synchronously walk the build directory, read each file and calculate its
 * SHA 256 hash, and create a mapping of hashes to Resource objects.
 * @param {PercyClient} percyClient
 * @param {Array<string>} buildDirs the directory to look in for assets.
 * @param {Array<string>} rootDirs The directory for the root of the app.
 *     This is used to change a local path to a url path.
 * @return {Object<string,PercyClient.Resource>}
 *     {@see https://github.com/percy/percy-js/blob/master/src/main.js#L9}
 */
Reads the filesystem for assets and assembles an object to be handed to percy
so it can upload the assets.
Synchronously walk the build directory, read each file and calculate its
SHA 256 hash, and create a mapping of hashes to Resource objects.
@param {PercyClient} percyClient
@param {Array} buildDirs the directory to look in for assets.
@param {Array} rootDirs The directory for the root of the app.
This is used to change a local path to a url path.
Reads the filesystem for assets and assembles an object to be handed to percy so it can upload the assets . Synchronously walk the build directory read each file and calculate its SHA 256 hash and create a mapping of hashes to Resource objects . @param { PercyClient } percyClient @param { Array } buildDirs the directory to look in for assets . @param { Array } rootDirs The directory for the root of the app . This is used to change a local path to a url path .
function gatherBuildResources(percyClient, buildDirs, rootDirs) {
  const hashToResource = {};
  const paths = globby.sync(buildDirs, {absolute: true, nodir: true});
  let absolutePath, resourceUrl, content, sha;
  for (let i = 0; i < paths.length; i++) {
    absolutePath = paths[i];
    resourceUrl = absolutePath;
    rootDirs.forEach((rootDir) => {
      resourceUrl = resourceUrl.replace(rootDir, '');
    });
    if (resourceUrl.charAt(0) !== '/') resourceUrl = '/' + resourceUrl;
    if (fs.statSync(absolutePath)['size'] > MAX_FILE_SIZE_BYTES) {
      console.warn('\n[percy][WARNING] Skipping large build resource: ',
          resourceUrl);
      continue;
    }
    content = fs.readFileSync(absolutePath);
    sha = crypto.createHash('sha256').update(content).digest('hex');
    hashToResource[sha] = percyClient.makeResource({
      resourceUrl: encodeURI(resourceUrl),
      sha: sha,
      localPath: absolutePath,
    });
  }
  return hashToResource;
}
function gatherBuildResources ( percyClient , buildDirs , rootDirs ) { const hashToResource = { } ; const paths = globby . sync ( buildDirs , { absolute : true , nodir : true } ) ; let absolutePath , resourceUrl , content , sha ; for ( let i = 0 ; i < paths . length ; i ++ ) { absolutePath = paths [ i ] ; resourceUrl = absolutePath ; rootDirs . forEach ( ( rootDir ) => { resourceUrl = resourceUrl . replace ( rootDir , '' ) ; } ) ; if ( resourceUrl . charAt ( 0 ) !== '/' ) resourceUrl = '/' + resourceUrl ; if ( fs . statSync ( absolutePath ) [ 'size' ] > MAX_FILE_SIZE_BYTES ) { console . warn ( '\n[percy][WARNING] Skipping large build resource: ' , resourceUrl ) ; continue ; } content = fs . readFileSync ( absolutePath ) ; sha = crypto . createHash ( 'sha256' ) . update ( content ) . digest ( 'hex' ) ; hashToResource [ sha ] = percyClient . makeResource ( { resourceUrl : encodeURI ( resourceUrl ) , sha : sha , localPath : absolutePath , } ) ; } return hashToResource ; }
Reads the filesystem for assets and assembles an object to be handed to percy
 so it can upload the assets.
Reads the filesystem for assets and assembles an object to be handed to percy so it can upload the assets .
// Skip large files.