function checkOptimizeFileError(config, input, output, error) {
  if (error.code == 'EISDIR') {
    return optimizeFolder(config, input, output);
  } else if (error.code == 'ENOENT') {
    return Promise.reject(
      new Error(`Error: no such file or directory '${error.path}'.`),
    );
  }
  return Promise.reject(error);
}
Check for errors, if it's a dir optimize the dir.

@param {any} config
@param {string} input
@param {string} output
@param {Error & { code: string, path: string }} error
@return {Promise<void>}