<commit_before>import { app, dialog, shell } from 'electron';
import GhReleases from 'electron-gh-releases';

let checking = false;

export default (mainWindow, icon, notify) => {
  if (checking) return;

  checking = true;
  const updater = new GhReleases({
    repo: 'jhen0409/react-native-debugger',
    currentVersion: app.getVersion(),
  });

  updater.check((err, status) => {
    if (
      process.platform === 'linux' &&
      err.message === 'This platform is not supported.'
    ) {
      err = null; // eslint-disable-line
      status = true; // eslint-disable-line
    }
    if (notify && err) {
      dialog.showMessageBox(mainWindow, {
        type: 'info',
        buttons: ['OK'],
        title: 'React Native Debugger',
        icon,
        message: err.message,
      });
      checking = false;
      return;
    }
    if (err || !status) return;
    if (notify) {
      const index = dialog.showMessageBox(mainWindow, {
        type: 'info',
        buttons: ['Download', 'Later'],
        title: 'React Native Debugger',
        icon,
        message: 'The new version has been released.',
      });
      if (index === 1) return;
      shell.openExternal('https://github.com/jhen0409/react-native-debugger/releases');
      checking = false;
      return;
    }
    if (process.env.NODE_ENV === 'production' && process.platform === 'darwin') {
      updater.download();
    }
  });

  updater.on('update-downloaded', ([, releaseNotes, releaseName]) => {
    const index = dialog.showMessageBox(mainWindow, {
      type: 'info',
      buttons: ['Restart', 'Later'],<commit_msg>Add log to update.js for debug<commit_after>import { app, dialog, shell } from 'electron';
import GhReleases from 'electron-gh-releases';

let checking = false;

export default (mainWindow, icon, notify) => {
  if (checking) {
    console.log('[Updater] Already checking...');
    return;
  }

  checking = true;
  const updater = new GhReleases({
    repo: 'jhen0409/react-native-debugger',
    currentVersion: app.getVersion(),
  });

  updater.check((err, status) => {
    if (
      process.platform === 'linux' &&
      err.message === 'This platform is not supported.'
    ) {
      err = null; // eslint-disable-line
      status = true; // eslint-disable-line
    }
    if (notify && err) {
      dialog.showMessageBox(mainWindow, {
        type: 'info',
        buttons: ['OK'],
        title: 'React Native Debugger',
        icon,
        message: err.message,
      });
      checking = false;
      console.log('[Updater]', err.message);
      return;
    }
    if (err || !status) {
      console.log('[Updater] Error', err && err.message, status);
      checking = false;
      return;
    }
    if (notify) {
      const index = dialog.showMessageBox(mainWindow, {
        type: 'info',
        buttons: ['Download', 'Later'],
        title: 'React Native Debugger',
        icon,
        message: 'The new version has been released.',
      });
      if (index === 1) return;
      shell.openExternal('https://github.com/jhen0409/react-native-debugger/releases');
      checking = false;
      console.log('[Updater] Open external link.');
      return;
    }
    if (process.env.NODE_ENV === 'production' && process.platform === 'darwin') {
      updater.download();
      console.log('[Updater] Starting download...');
    }
  });
  console.log('[Updater] Checking updates...');

  updater.on('update-downloaded', ([, releaseNotes, releaseName]) => {
    console.log('[Updater] Downloaded.');
    const index = dialog.showMessageBox(mainWindow, {
      type: 'info',
      buttons: ['Restart', 'Later'],
{'fraction_non_alphanumeric': 0.15705216671266906, 'fraction_numerical': 0.0049682583494341705, 'mean_word_length': 2.5564278704612367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2531882', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1103, 'n_words': 262}