async function writeOutput(input, output, data) {
  if (output == '-') {
    process.stdout.write(data);
    return Promise.resolve();
  }

  await fs.promises.mkdir(path.dirname(output), { recursive: true });

  return fs.promises
    .writeFile(output, data, 'utf8')
    .catch((error) => checkWriteFileError(input, output, data, error));
}
Write result of an optimization.

@param {string} input
@param {string} output output file name. '-' for stdout
@param {string} data data to write
@return {Promise<void>}