<commit_before>'use strict'
const cbRimraf = require('rimraf')
const join = require('path').join

const initCmd = require('./init_cmd')
const getSaveType = require('../get_save_type')
const removeDeps = require('../remove_deps')
const binify = require('../binify')

function uninstallCmd (pkgsToUninstall, opts) {
  opts = Object.assign({}, require('../defaults'), opts)

  let cmd
  const uninstalledPkgs = []
  const saveType = getSaveType(opts)

  return initCmd(opts)
    .then(_ => { cmd = _ })
    .then(_ => {
      cmd.pkg.pkg.dependencies = cmd.pkg.pkg.dependencies || {}
      const pkgFullNames = pkgsToUninstall.map(dep => cmd.ctx.dependencies[cmd.pkg.path].find(_ => _.indexOf(dep + '@') === 0))
      tryUninstall(pkgFullNames.slice())
      if (cmd.ctx.dependencies[cmd.pkg.path]) {
        pkgFullNames.forEach(dep => {
          cmd.ctx.dependencies[cmd.pkg.path].splice(cmd.ctx.dependencies[cmd.pkg.path].indexOf(dep), 1)
        })
        if (!cmd.ctx.dependencies[cmd.pkg.path].length) {
          delete cmd.ctx.dependencies[cmd.pkg.path]
        }
      }
      return Promise.all(uninstalledPkgs.map(removePkgFromStore))
    })
    .then(_ => cmd.storeJsonCtrl.save({
      dependents: cmd.ctx.dependents,
      dependencies: cmd.ctx.dependencies
    }))
    .then(_ => Promise.all(pkgsToUninstall.map(dep => rimraf(join(cmd.ctx.root, 'node_modules', dep)))))
    .then(_ => saveType && removeDeps(cmd.pkg, pkgsToUninstall, saveType))
    .then(_ => cmd.unlock())
    .catch(err => {
      if (cmd && cmd.unlock) cmd.unlock()
      throw err
    })
<commit_msg>fix(uninstall): uninstall should not remove version from store.json<commit_after>'use strict'
const cbRimraf = require('rimraf')
const join = require('path').join

const initCmd = require('./init_cmd')
const getSaveType = require('../get_save_type')
const removeDeps = require('../remove_deps')
const binify = require('../binify')

function uninstallCmd (pkgsToUninstall, opts) {
  opts = Object.assign({}, require('../defaults'), opts)

  let cmd
  const uninstalledPkgs = []
  const saveType = getSaveType(opts)

  return initCmd(opts)
    .then(_ => { cmd = _ })
    .then(_ => {
      cmd.pkg.pkg.dependencies = cmd.pkg.pkg.dependencies || {}
      const pkgFullNames = pkgsToUninstall.map(dep => cmd.ctx.dependencies[cmd.pkg.path].find(_ => _.indexOf(dep + '@') === 0))
      tryUninstall(pkgFullNames.slice())
      if (cmd.ctx.dependencies[cmd.pkg.path]) {
        pkgFullNames.forEach(dep => {
          cmd.ctx.dependencies[cmd.pkg.path].splice(cmd.ctx.dependencies[cmd.pkg.path].indexOf(dep), 1)
        })
        if (!cmd.ctx.dependencies[cmd.pkg.path].length) {
          delete cmd.ctx.dependencies[cmd.pkg.path]
        }
      }
      return Promise.all(uninstalledPkgs.map(removePkgFromStore))
    })
    .then(_ => cmd.storeJsonCtrl.save({
      pnpm: cmd.ctx.pnpm,
      dependents: cmd.ctx.dependents,
      dependencies: cmd.ctx.dependencies
    }))
    .then(_ => Promise.all(pkgsToUninstall.map(dep => rimraf(join(cmd.ctx.root, 'node_modules', dep)))))
    .then(_ => saveType && removeDeps(cmd.pkg, pkgsToUninstall, saveType))
    .then(_ => cmd.unlock())
    .catch(err => {
      if (cmd && cmd.unlock) cmd.unlock()
      throw err
    })

{'fraction_non_alphanumeric': 0.16738461538461538, 'fraction_numerical': 0.0012307692307692308, 'mean_word_length': 3.2385919165580184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2184075', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1054, 'n_words': 179}