function checkFilesInDirectory(rootDir, dir, outputFiles) {
  fs.readdirSync(dir).forEach(fileOrDirName => {
    const fileOrDir = path.join(dir, fileOrDirName);

    if (fs.statSync(fileOrDir).isDirectory()) {
      checkFilesInDirectory(rootDir, fileOrDir, outputFiles);
    } else {
      const relativePath = path.relative(rootDir, fileOrDir);
      if (!(relativePath in outputFiles)) {
        throw new Error(`Expected ${relativePath} file in build output.`);
      }
    }
  });
}
Scans directory recursively and checks whether all files are present
in the build output.

@param {string} rootDir
@param {string} dir
@param {{ [key: string]: string }} outputFiles