<commit_before>import _ from 'lodash';

import catchAsyncError from '../../catchAsyncError';
import askUser from '../../askUser';
import { success, strong, attention } from '../../cliStyles';
import { createIgnoredModulesTable } from '../ignore';
import Config from '../../Config';

export const command = 'reset [modules...]';
export const describe = 'Choose ignored modules to reset';

export const handler = catchAsyncError(async (opts) => {
  let { modules: modulesToReset } = opts;
  let invalidModules = [];
  const config = new Config();
  const ignoredModules = _.keys(config.ignore);

  console.log(
    `Currently ignored modules:\n\n${createIgnoredModulesTable(config.ignore)}\n`
  );

  if (modulesToReset.length) {
    [modulesToReset, invalidModules] = _.partition(modulesToReset, moduleName =>
      _.includes(ignoredModules, moduleName)
    );

    if (invalidModules.length) {
      console.log(attention(
        `These modules are not in the ignored list: ${strong(invalidModules.join(', '))}\n`
      ));
    }
  }

  if (invalidModules.length) {
    modulesToReset = await askUser({
      type: 'checkbox',
      message: 'Select ignored modules to reset:',
      choices: ignoredModules,
      default: modulesToReset
    });
  }

  if (!modulesToReset.length) {
    return console.log('Nothing to reset');
  }

  console.log(
    `These ignored modules will be reset:\n\n${createIgnoredModulesTable(config.ignore, modulesToReset)}\n`
  );

  const confirm = await askUser({
    message: 'Are you sure?',
    type: 'confirm',
    default: false
  });

  if (!confirm) return;

  config.ignore = _.omit(config.ignore, modulesToReset);
  config.save();

  console.log(success('\nDone!'));
});
<commit_msg>Fix `ignore reset` command<commit_after>import _ from 'lodash';

import catchAsyncError from '../../catchAsyncError';
import askUser from '../../askUser';
import { success, strong, attention } from '../../cliStyles';
import { createIgnoredModulesTable } from '../ignore';
import Config from '../../Config';

export const command = 'reset [modules...]';
export const describe = 'Choose ignored modules to reset';

export const handler = catchAsyncError(async (opts) => {
  let { modules: modulesToReset } = opts;
  let invalidModules = [];
  const config = new Config();
  const ignoredModules = _.keys(config.ignore);

  console.log(
    `Currently ignored modules:\n\n${createIgnoredModulesTable(config.ignore)}\n`
  );

  if (modulesToReset.length) {
    [modulesToReset, invalidModules] = _.partition(modulesToReset, moduleName =>
      _.includes(ignoredModules, moduleName)
    );

    if (invalidModules.length) {
      console.log(attention(
        `These modules are not in the ignored list: ${strong(invalidModules.join(', '))}\n`
      ));
    }
  }

  if (!modulesToReset.length || invalidModules.length) {
    modulesToReset = await askUser({
      type: 'checkbox',
      message: 'Select ignored modules to reset:',
      choices: ignoredModules,
      default: modulesToReset
    });
    console.log();
  }

  if (!modulesToReset.length) {
    return console.log(attention('Nothing to reset'));
  }

  console.log(
    `These ignored modules will be reset:\n\n${createIgnoredModulesTable(config.ignore, modulesToReset)}\n`
  );

  const confirm = await askUser({
    message: 'Are you sure?',
    type: 'confirm',
    default: false
  });

  if (!confirm) return;

  config.ignore = _.omit(config.ignore, modulesToReset);
  config.save();

  console.log(success('\nDone!'));
});

{'fraction_non_alphanumeric': 0.14654927577392787, 'fraction_numerical': 0.0, 'mean_word_length': 3.5799739921976594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3489549', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1027, 'n_words': 269}