function checkWriteFileError(input, output, data, error) {
  if (error.code == 'EISDIR' && input) {
    return fs.promises.writeFile(
      path.resolve(output, path.basename(input)),
      data,
      'utf8',
    );
  } else {
    return Promise.reject(error);
  }
}
Check for saving file error. If the output is a dir, then write file there.

@param {string} input
@param {string} output
@param {string} data
@param {Error & { code: string }} error
@return {Promise<void>}