function writeFile(filePath, output, outputMode) {
  return new Promise((resolve, reject) => {
    fs.mkdir(path.dirname(filePath), {recursive: true}, (err) => {
      if (err && err.code !== 'EEXIST') {
        return reject(err);
      }
      fs.writeFile(filePath, output, (err) => {
        if (err) {
          return reject(err);
        }
        log.log('Printer', `${OutputMode[outputMode]} output written to ${filePath}`);
        resolve();
      });
    });
  });
}
Writes the output to a file.
@param {string} filePath
@param {string} output
@param {LH.OutputMode} outputMode
@return {Promise<void>}