<commit_before>'use strict';

const repoManager = require('../lib/repoManager');

class Install {
  constructor(options) {
    // Todo: allow multiple repos for mods.
    this.manager = new repoManager(options);
    this.manager.setup();
  }

  clearLockfile() {
    return this.manager.clearLockfile();
  }

  clearMods() {
    return this.manager.clearMods();
  }

  // mods argument can be:
  // an object {'name1' => 'version1', 'name2', => 'version2'}
  // or a list [['name1', 'version1'], ['name2', 'version2']]
  run(mods) {
    let promises = [];

    if(mods) {
      if(!Array.isArray(mods) && typeof mods === 'object') {
        mods = Object.entries(mods);
      }
      for(let [mod, version] of mods) {
        promises.push(this.install(mod, version));
      }
    }
    return Promise.all(promises);
  }

  install(mod, version) {
    let repo = this.matchRepo(mod, version);
    return repo.remove(mod, true)
      .catch((e) => { /* We ignore errors for now. */ })
      .then(() => this.repoGet(repo, mod, version));
  }

  matchRepo(mod, version) {
    let matchRepo = this.manager.default;
    for(let name in this.manager.repos) {
      let repo = this.manager.repos[name];
      if(repo.checkRepository(mod, version)) {
        matchRepo = repo;<commit_msg>Default installation to any package.<commit_after>'use strict';

const repoManager = require('../lib/repoManager');

class Install {
  constructor(options) {
    // Todo: allow multiple repos for mods.
    this.manager = new repoManager(options);
    this.manager.setup();
  }

  clearLockfile() {
    return this.manager.clearLockfile();
  }

  clearMods() {
    return this.manager.clearMods();
  }

  // mods argument can be:
  // an object {'name1' => 'version1', 'name2', => 'version2'}
  // or a list [['name1', 'version1'], ['name2', 'version2']]
  run(mods) {
    let promises = [];

    if(mods) {
      if(!Array.isArray(mods) && typeof mods === 'object') {
        mods = Object.entries(mods);
      }
      for(let [mod, version] of mods) {
        promises.push(this.install(mod, version));
      }
    }
    return Promise.all(promises);
  }

  install(mod, version) {
    version = version || '*';
    let repo = this.matchRepo(mod, version);
    return repo.remove(mod, true)
      .catch((e) => { /* We ignore errors for now. */ })
      .then(() => this.repoGet(repo, mod, version));
  }

  matchRepo(mod, version) {
    let matchRepo = this.manager.default;
    for(let name in this.manager.repos) {
      let repo = this.manager.repos[name];
      if(repo.checkRepository(mod, version)) {
        matchRepo = repo;
{'fraction_non_alphanumeric': 0.16673040152963672, 'fraction_numerical': 0.006118546845124283, 'mean_word_length': 2.7968069666182873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3253047', 'n_tokens_mistral': 868, 'n_tokens_neox': 859, 'n_words': 195}