<commit_before>'use babel'
const FS = require('fs')
const Path = require('path')
const View = require('./view')
import {installPackages} from './helper'

window.__sb_package_deps = window.__sb_package_deps || []

// Private
export function packagesToInstall(packageName, enablePackages) {
  const packageDeps = atom.packages.getLoadedPackage(packageName).metadata['package-deps'] || []
  const packagesToInstall = []
  packageDeps.forEach(function(name) {
    if (__sb_package_deps.indexOf(name) === -1) {
      __sb_package_deps.push(name)
      if (!atom.packages.resolvePackagePath(name)) {
        packagesToInstall.push(name)
      } else if(!atom.packages.getActivePackage(name) && enablePackages) {
        atom.packages.enablePackage(name)
        atom.packages.activatePackage(name)
      }
    }
  })
  return packagesToInstall
}

// Public
export function install(packageName, enablePackages = false) {
  if (!packageName) throw new Error('packageName is required')

  const packagesToInstall = packagesToInstall(packageName, enablePackages)
  if (packagesToInstall.length) {
    return installPackage(packageName, packagesToInstall)
  } else return Promise.resolve()
}

// Private
export function installPackage(packageName, packageNames) {
  const view = new View(packageName, packageNames)
  return view.createNotification().then(() =>
    installPackages(packageNames, function(name) {
      view.markFinished()
      atom.packages.enablePackage(name)
      atom.packages.activatePackage(name)
    }, function(detail) {
      view.notification.dismiss()
      atom.notifications.addError(`Error installing ${packageName} dependencies`, {detail})
    })
  )
}<commit_msg>:art: Fix a variable name conflict introduced by last commit<commit_after>'use babel'
const FS = require('fs')
const Path = require('path')
const View = require('./view')
import {installPackages} from './helper'

window.__sb_package_deps = window.__sb_package_deps || []

// Private
export function packagesToInstall(packageName, enablePackages) {
  const packageDeps = atom.packages.getLoadedPackage(packageName).metadata['package-deps'] || []
  const packagesToInstall = []
  packageDeps.forEach(function(name) {
    if (__sb_package_deps.indexOf(name) === -1) {
      __sb_package_deps.push(name)
      if (!atom.packages.resolvePackagePath(name)) {
        packagesToInstall.push(name)
      } else if(!atom.packages.getActivePackage(name) && enablePackages) {
        atom.packages.enablePackage(name)
        atom.packages.activatePackage(name)
      }
    }
  })
  return packagesToInstall
}

// Public
export function install(packageName, enablePackages = false) {
  if (!packageName) throw new Error('packageName is required')

  const toInstall = packagesToInstall(packageName, enablePackages)
  if (toInstall.length) {
    return installPackage(packageName, toInstall)
  } else return Promise.resolve()
}

// Private
export function installPackage(packageName, packageNames) {
  const view = new View(packageName, packageNames)
  return view.createNotification().then(() =>
    installPackages(packageNames, function(name) {
      view.markFinished()
      atom.packages.enablePackage(name)
      atom.packages.activatePackage(name)
    }, function(detail) {
      view.notification.dismiss()
      atom.notifications.addError(`Error installing ${packageName} dependencies`, {detail})
    })
  )
}
{'fraction_non_alphanumeric': 0.11965811965811966, 'fraction_numerical': 0.0005894488653109342, 'mean_word_length': 4.491909385113269, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1485899', 'n_tokens_mistral': 964, 'n_tokens_neox': 954, 'n_words': 191}