<commit_before>const fetch = require('node-fetch')
const constants = require('../shared/constants')
const pkg = require('../package.json')
const {dialog, shell} = require('electron')
const compareVersion = require('compare-version')

class Update {
  /**
  * Checks to see if there is an update
  */
  checkNow (window) {
    fetch(constants.UPDATE_CHECK_URL).then((res) => {
      return res.json()
    }).then((json) => {
      const newRelease = json.find((release) => {
        let tag = release.tag_name
        tag = tag.indexOf('v' === 0) ? tag.substr(1) : tag
        return (pkg.prerelease === true || release.prerelease === false) && compareVersion(tag, pkg.version) >= 1
      })

      if (newRelease) {
        let tag = newRelease.tag_name
        tag = tag.indexOf('v' === 0) ? tag.substr(1) : tag
        dialog.showMessageBox(window, {
          type: 'question',
          title: 'Updates Available',
          message: 'Version ' + tag + ' is now available. Do you want to download it now?',
          buttons: ['Download Now', 'Download Later'],
          defaultId: 1
        }, (response) => {
          if (response === 0) {
            shell.openExternal(constants.GITHUB_RELEASES_URL)
          }
        })
      }
    })
  }
}

module.exports = new Update()
<commit_msg>Fix update code<commit_after>const fetch = require('node-fetch')
const constants = require('../shared/constants')
const pkg = require('../package.json')
const {dialog, shell} = require('electron')
const compareVersion = require('compare-version')

class Update {
  /**
  * Checks to see if there is an update
  */
  checkNow (window) {
    fetch(constants.UPDATE_CHECK_URL).then((res) => {
      return res.json()
    }).then((json) => {
      const newRelease = json.find((release) => {
        let tag = release.tag_name
        tag = tag.indexOf('v') === 0 ? tag.substr(1) : tag
        console.log(release.tag_name, tag)
        return (pkg.prerelease === true || release.prerelease === false) && compareVersion(tag, pkg.version) >= 1
      })

      if (newRelease) {
        let tag = newRelease.tag_name
        tag = tag.indexOf('v') === 0 ? tag.substr(1) : tag
        dialog.showMessageBox(window, {
          type: 'question',
          title: 'Updates Available',
          message: 'Version ' + tag + ' is now available. Do you want to download it now?',
          buttons: ['Download Now', 'Download Later'],
          defaultId: 1
        }, (response) => {
          if (response === 0) {
            shell.openExternal(constants.GITHUB_RELEASES_URL)
          }
        })
      }
    })
  }
}

module.exports = new Update()

{'fraction_non_alphanumeric': 0.15270935960591134, 'fraction_numerical': 0.005305039787798408, 'mean_word_length': 2.424124513618677, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6242572', 'n_tokens_mistral': 795, 'n_tokens_neox': 780, 'n_words': 194}