async function mirrorFile(file, contents) {
  ensureDirectoryExists(file);
  // zip files cannot just be written to FS using utf-8 encoding..
  if (file.endsWith('.zip')) {
    const zipResult = await writeZIP(contents);
    contents = new Uint8Array(await zipResult.arrayBuffer());
  }
  await fs.promises.writeFile(file, contents);
}
@param {string} file
@param {string | Record<string, string>} contents