<commit_before>fs = require 'fs'
path = require 'path'
temp = require 'temp'
_ = require 'underscore'

temp.track()

module.exports = (grunt) ->
  spawn = (options, callback) ->
    spawnedProcess = grunt.util.spawn(options, callback)
    spawnedProcess.on('error', callback)

  grunt.registerTask 'create-windows-installer', 'Create the Windows installer', ->
    @requiresConfig("#{@name}.appDirectory")

    done = @async()

    {appDirectory, loadingGif, outputDirectory} = grunt.config(@name)
    outputDirectory ?= path.resolve('.')
    loadingGif ?= path.resolve(__dirname, 'resources', 'install-spinner.gif')

    metadata = grunt.file.readJSON(path.join(appDirectory, 'resources', 'app', 'package.json'))<commit_msg>Use spawn from Atom's task helpers<commit_after>ChildProcess = require 'child_process'
fs = require 'fs'
path = require 'path'
temp = require 'temp'
_ = require 'underscore'

temp.track()

module.exports = (grunt) ->
  spawn = (options, callback) ->
    stdout = []
    stderr = []
    error = null

    spawnedProcess = ChildProcess.spawn(options.cmd, options.args, options.opts)
    spawnedProcess.stdout.on 'data', (data) -> stdout.push(data.toString())
    spawnedProcess.stderr.on 'data', (data) -> stderr.push(data.toString())
    spawnedProcess.on 'error', (processError) -> error ?= processError
    spawnedProcess.on 'close', (exitCode, signal) ->
      error ?= new Error(signal) if exitCode != 0
      results = {stderr: stderr.join(''), stdout: stdout.join(''), code: exitCode}
      grunt.log.error results.stderr if exitCode != 0
      callback(error, results, exitCode)

  grunt.registerTask 'create-windows-installer', 'Create the Windows installer', ->
    @requiresConfig("#{@name}.appDirectory")

    done = @async()

    {appDirectory, loadingGif, outputDirectory} = grunt.config(@name)
    outputDirectory ?= path.resolve('.')
    loadingGif ?= path.resolve(__dirname, 'resources', 'install-spinner.gif')

    metadata = grunt.file.readJSON(path.join(appDirectory, 'resources', 'app', 'package.json'))
{'fraction_non_alphanumeric': 0.15632633121641426, 'fraction_numerical': 0.0009770395701025891, 'mean_word_length': 4.333333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5722886', 'n_tokens_mistral': 646, 'n_tokens_neox': 636, 'n_words': 140}