<commit_before>import setup from './lib/setup'
import verify from './lib/verify'
import pickStrategies from './lib/pickStrategies'
import rimraf from 'rimraf'
import Promise from 'bluebird'

const rm = Promise.promisify(rimraf)

function* run() {
  const sandboxPath = yield setup()
  const verifyResult = yield verify(sandboxPath)
  if (verifyResult === false) {
    yield rm(sandboxPath)
    return '`npm install` works fine'
  }
  
  const strategies = pickStrategies(verifyResult)
  for (let strategy of strategies) {
    yield strategy(sandboxPath)
  }
  
  const reVerifyResult = yield verify(sandboxPath)
  if (reVerifyResult === false) {
    yield rm(sandboxPath)
    return '`npm install` is now working'
  }
  
  yield rm(sandboxPath)
  return 'Unable to fix `npm install` issues'
}

run = Promise.coroutine(run)

run()
  .then((msg) => console.log(msg))
  .catch((e) => console.warn(e))

// let sandboxPath = null
// setup()
//   .then(path => {
//     sandboxPath = path
//     return verify(sandboxPath)
//   })
//   .then(err => {
//     if (err === false) {
//       throw '`npm install` works fine. Chill bro'
//     }
//     return pickStrategies(err)
//   })
//   .then(strategies => Promise.all(strategies.map(strategy => strategy(sandboxPath))))
//   .then(() => verify(sandboxPath))
//   .then(err => {
//     if (err === false) {
//       console.log('yay fixed')
//     } else {
//       console.log('no dice')
//     }
//   })
//   .finally(() => {
//     rimraf(sandboxPath, {}, () => {})
//   })
<commit_msg>Add some comments and remove dead code<commit_after>import setup from './lib/setup'
import verify from './lib/verify'
import pickStrategies from './lib/pickStrategies'
import rimraf from 'rimraf'
import Promise from 'bluebird'

const rm = Promise.promisify(rimraf)

function* run() {
  // Setup our test environment - this involves copying from the source
  // into a temporary directory so we aren't affecting actual versions
  const sandboxPath = yield setup()
  
  // Verify there is actually an issue with `npm install`
  const verifyResult = yield verify(sandboxPath)
  if (verifyResult === false) {
    yield rm(sandboxPath)
    return '`npm install` works fine'
  }
  
  // Based on the error message from `npm install`, pick a list
  // of strategies to fix the error and then execute each strategy
  const strategies = pickStrategies(verifyResult)
  for (let strategy of strategies) {
    yield strategy(sandboxPath)
  }
  
  // Check again if `npm install` works
  const reVerifyResult = yield verify(sandboxPath)
  if (reVerifyResult === false) {
    yield rm(sandboxPath)
    return '`npm install` is now working'
  }
  
  yield rm(sandboxPath)
  return 'Unable to fix `npm install` issues'
}

run = Promise.coroutine(run)

run()
  .then((msg) => console.log(msg))
  .catch((e) => console.warn(e))

{'fraction_non_alphanumeric': 0.13642756680731363, 'fraction_numerical': 0.0, 'mean_word_length': 3.1838235294117645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7668199', 'n_tokens_mistral': 925, 'n_tokens_neox': 904, 'n_words': 269}