<commit_before>var os = require('os')
var webpack = require('webpack')
var cfg = require('./webpack.config.production.js')
var packager = require('electron-packager')
var assign = require('object-assign')
var del = require('del')
var latest = require('github-latest-release')
var argv = require('minimist')(process.argv.slice(2))
var pkgJson = require('./package.json')
var devDeps = Object.keys(pkgJson.devDependencies)

var appName = argv.name || argv.n || 'Kimochi'
var shouldUseAsar = argv.asar || argv.a || true
var shouldBuildAll = argv.all || false

var DEFAULT_OPTS = {
  dir: './',
  name: appName,
  asar: shouldUseAsar,
  'version-string': {
    CompanyName: pkgJson.name,
    FileDescription: pkgJson.description,
    FileVersion: pkgJson.version,
    InternalName: pkgJson.windowsBuild.executable,
    LegalCopyright: pkgJson.copyright,
    OriginalFilename: pkgJson.windowsBuild.executable,
    ProductName: pkgJson.name,
    ProductVersion: pkgJson.version
  },
  ignore: [
    '/test($|/)',
    '/tools($|/)',
    '/release($|/)'
  ].concat(devDeps.map(function(name) { return '/node_modules/' + name + '($|/)' }))
}

var icon = argv.icon || argv.i || 'logo_large.ico'

if (icon) {
  DEFAULT_OPTS.icon = icon
}

var version = argv.version || argv.v

if (version) {
  DEFAULT_OPTS.version = version
  startPack()
} else {
  latest('atom', 'electron', function(err, res) {
    if (err) {
      DEFAULT_OPTS.version = '0.28.3'
    } else {
      DEFAULT_OPTS.version = res.name.split('v')[1]
    }
    startPack()
  })
}


function startPack() {
  console.log('start pack...')
  webpack(cfg, function(err, stats) {
    if (err) return console.error(err)
      console.log ("Webpack done. stats:" + stats)
    del('release', function(err, paths) {
      if (err) return console.error(err)
      if (shouldBuildAll) {
        // build for all platforms
        var archs = ['ia32', 'x64']
        var platforms = ['linux', 'win32', 'darwin']

        platforms.forEach(function (plat) {
          archs.forEach(function (arch) {
            pack(plat, arch, log(plat, arch))
          })
        })
      } else {
        // build for current platform only
        pack(os.platform(), os.arch(), log(os.platform(), os.arch()))
      }<commit_msg>package to use electron version tied to package.json electron version<commit_after>var os = require('os')
var webpack = require('webpack')
var cfg = require('./webpack.config.production.js')
var packager = require('electron-packager')
var assign = require('object-assign')
var del = require('del')
var latest = require('github-latest-release')
var argv = require('minimist')(process.argv.slice(2))
var pkgJson = require('./package.json')
var devDeps = Object.keys(pkgJson.devDependencies)

var appName = argv.name || argv.n || 'Kimochi'
var shouldUseAsar = argv.asar || argv.a || true
var shouldBuildAll = argv.all || false

var DEFAULT_OPTS = {
  dir: './',
  name: appName,
  asar: shouldUseAsar,
  'version-string': {
    CompanyName: pkgJson.name,
    FileDescription: pkgJson.description,
    FileVersion: pkgJson.version,
    InternalName: pkgJson.windowsBuild.executable,
    LegalCopyright: pkgJson.copyright,
    OriginalFilename: pkgJson.windowsBuild.executable,
    ProductName: pkgJson.name,
    ProductVersion: pkgJson.version
  },
  ignore: [
    '/test($|/)',
    '/tools($|/)',
    '/release($|/)'
  ].concat(devDeps.map(function(name) { return '/node_modules/' + name + '($|/)' }))
}

var icon = argv.icon || argv.i || 'logo_large.ico'

if (icon) {
  DEFAULT_OPTS.icon = icon
}

var version = argv.version || argv.v

if (version) {
  DEFAULT_OPTS.version = version
  startPack()
} else {
  DEFAULT_OPTS.version = pkgJson.devDependencies['electron-prebuilt']
  startPack()
}

function startPack() {
  console.log('start pack...')
  webpack(cfg, function(err, stats) {
    if (err) return console.error(err)
      console.log ("Webpack done. stats:" + stats)
    del('release', function(err, paths) {
      if (err) return console.error(err)
      if (shouldBuildAll) {
        // build for all platforms
        var archs = ['ia32', 'x64']
        var platforms = ['linux', 'win32', 'darwin']

        platforms.forEach(function (plat) {
          archs.forEach(function (arch) {
            pack(plat, arch, log(plat, arch))
          })
        })
      } else {
        // build for current platform only
        pack(os.platform(), os.arch(), log(os.platform(), os.arch()))
      }
{'fraction_non_alphanumeric': 0.15926424405563033, 'fraction_numerical': 0.004262000897263347, 'mean_word_length': 3.2751677852348995, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6012595', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1432, 'n_words': 326}