<commit_before>'use strict'

/**
 * Module dependencies
 */
const path = require('path')
const co = require('co')
const os = require('./os')
const pget = require('pget')
const home = require('user-home')
const extract = require('extract-zip')
const pify = require('pify')
const exists = require('path-exists')
const config = require('./config')
require('shelljs/global')

module.exports = co.wrap(function* (version) {
  try {
    // Create cache dir
    const cacheDir = path.join(home, '.nwjs')
    mkdir('-p', cacheDir)
    // check if has cached nwjs in this version
    if (exists.sync(`${cacheDir}/${version}`)) {
      return console.log(`A cached nwjs already located in ${cacheDir}/${version}`.red)
    }
    // Download the nwjs
    const fileName = `nwjs-v${version}-${os.platform}-${os.arch}`
    const ext = os.platform === 'linux' ? 'tar.gz' : 'zip'
    const url = `http://dl.nwjs.io/v${version}/${fileName}.${ext}`
    yield pget(url, {dir: cacheDir, target: `${version}.${ext}`, verbose: true, proxy: process.env.HTTP_PROXY})
    // extract both zip and tarball
    const from = `${cacheDir}/${version}.${ext}`
    if (os.platform === 'linux') {
      exec(`tar -xzvf ${from}`, {silent: true})
    } else {
      yield pify(extract)(from, {dir: cacheDir})<commit_msg>extract to cacheDir, fixed #8<commit_after>'use strict'

/**
 * Module dependencies
 */
const path = require('path')
const co = require('co')
const os = require('./os')
const pget = require('pget')
const home = require('user-home')
const extract = require('extract-zip')
const pify = require('pify')
const exists = require('path-exists')
const config = require('./config')
require('shelljs/global')

module.exports = co.wrap(function* (version) {
  try {
    // Create cache dir
    const cacheDir = path.join(home, '.nwjs')
    mkdir('-p', cacheDir)
    // check if has cached nwjs in this version
    if (exists.sync(`${cacheDir}/${version}`)) {
      return console.log(`A cached nwjs already located in ${cacheDir}/${version}`.red)
    }
    // Download the nwjs
    const fileName = `nwjs-v${version}-${os.platform}-${os.arch}`
    const ext = os.platform === 'linux' ? 'tar.gz' : 'zip'
    const url = `http://dl.nwjs.io/v${version}/${fileName}.${ext}`
    yield pget(url, {dir: cacheDir, target: `${version}.${ext}`, verbose: true, proxy: process.env.HTTP_PROXY})
    // extract both zip and tarball
    const from = `${cacheDir}/${version}.${ext}`
    if (os.platform === 'linux') {
      exec(`tar -xzvf ${from} -C ${cacheDir}`, {silent: true})
    } else {
      yield pify(extract)(from, {dir: cacheDir})
{'fraction_non_alphanumeric': 0.19238168526356292, 'fraction_numerical': 0.00038476337052712584, 'mean_word_length': 3.676258992805755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2587684', 'n_tokens_mistral': 848, 'n_tokens_neox': 853, 'n_words': 223}