async function generateLanguage(language) {
  // Run generator
  const generatedFiles = await languageGen
    .runActions({ language, test: true })
    .then(handleResult)
    .then(feedbackToUser(`Added new language: '${language}'`))
    .then(changes =>
      changes.reduce((acc, change) => {
        const pathWithRemovedAnsiEscapeCodes = change.path.replace(
          /* eslint-disable-next-line no-control-regex */
          /(\u001b\[3(?:4|9)m)/g,
          '',
        );
        const obj = {};
        obj[pathWithRemovedAnsiEscapeCodes] = change.type;
        return Object.assign(acc, obj);
      }, {}),
    )
    .catch(reason => reportErrors(reason));

  // Run eslint on modified and added JS files
  const lintingTasks = Object.keys(generatedFiles)
    .filter(
      filePath =>
        generatedFiles[filePath] === 'modify' ||
        generatedFiles[filePath] === 'add',
    )
    .filter(filePath => filePath.endsWith('.js'))
    .map(async filePath => {
      const result = await runLintingOnFile(filePath)
        .then(reportSuccess(`Linting test passed for '${filePath}'`))
        .catch(reason => reportErrors(reason));

      return result;
    });

  await Promise.all(lintingTasks);

  // Restore modified files
  const restoreTasks = Object.keys(generatedFiles)
    .filter(filePath => generatedFiles[filePath] === 'backup')
    .map(async filePath => {
      const result = await restoreModifiedFile(filePath)
        .then(
          feedbackToUser(
            `Restored file: '${filePath.replace(
              `.${BACKUPFILE_EXTENSION}`,
              '',
            )}'`,
          ),
        )
        .catch(reason => reportErrors(reason));

      return result;
    });

  await Promise.all(restoreTasks);

  // Remove backup files and added files
  const removalTasks = Object.keys(generatedFiles)
    .filter(
      filePath =>
        generatedFiles[filePath] === 'backup' ||
        generatedFiles[filePath] === 'add',
    )
    .map(async filePath => {
      const result = await removeFile(filePath)
        .then(feedbackToUser(`Removed '${filePath}'`))
        .catch(reason => reportErrors(reason));

      return result;
    });

  await Promise.all(removalTasks);

  return language;
}
Test the language generator and rollback when successful
@param {string} language
@returns {Promise<*>}