<commit_before>const {dialog} = require('electron').remote
import {ipcRenderer} from 'electron'

/**
 * We want to make sure that people have installed the app in a
 * reasonable location.
 *
 * On the Mac, you can accidentally run the app from the DMG. If you do
 * this, it will no longer auto-update. It's also common for Mac users to
 * leave their app in the /Downloads folder (which frequently gets
 * erased!).
 */

function onNotificationActionTaken(numAsks) {
  return (buttonIndex) => {
    if (buttonIndex === 0) {
      ipcRenderer.send("move-to-applications")
    }

    if (numAsks >= 1) {
      if (buttonIndex === 1) {
        NylasEnv.config.set("asksAboutAppMove", 5)
      } else {
        NylasEnv.config.set("asksAboutAppMove", numAsks + 1)
      }
    } else {
      NylasEnv.config.set("asksAboutAppMove", numAsks + 1)
    }
  }
}

export function activate() {
  if (NylasEnv.inDevMode() || NylasEnv.inSpecMode()) { return; }

  if (process.platform !== "darwin") { return; }

  const appRe = /Applications/gi;
  if (appRe.test(process.argv[0])) { return; }

  // If we're in Volumes, that means we've launched from the DMG. This
  // is unsupported. We should optimistically move.
  const volTest = /Volumes/gi;
  if (volTest.test(process.argv[0])) {
    ipcRenderer.send("move-to-applications");
    return;
  }

  const numAsks = NylasEnv.config.get("asksAboutAppMove")
  if (numAsks >= 5) return;

  let buttons;
  if (numAsks >= 1) {
    buttons = [
      "Move to Applications folder",
      "Don't ask again",
      "Do not move",
    ]
  } else {
    buttons = [
      "Move to Applications folder",
      "Do not move",
    ]
  }

  let msg = `We recommend that you move N1 to your Applications folder to get updates correctly and keep this folder uncluttered.`

  const CANCEL_ID = 3;

  dialog.showMessageBox({
    type: "question",
    buttons: buttons,
    title: "A Better Place to Install N1",
    message: "Move to Applications folder?",
    detail: msg,
    defaultId: 0,
    cancelId: CANCEL_ID,
  }, onNotificationActionTaken(numAsks))
}

export function deactivate() {
}<commit_msg>fix(lint): Change variable to const<commit_after>const {dialog} = require('electron').remote
import {ipcRenderer} from 'electron'

/**
 * We want to make sure that people have installed the app in a
 * reasonable location.
 *
 * On the Mac, you can accidentally run the app from the DMG. If you do
 * this, it will no longer auto-update. It's also common for Mac users to
 * leave their app in the /Downloads folder (which frequently gets
 * erased!).
 */

function onNotificationActionTaken(numAsks) {
  return (buttonIndex) => {
    if (buttonIndex === 0) {
      ipcRenderer.send("move-to-applications")
    }

    if (numAsks >= 1) {
      if (buttonIndex === 1) {
        NylasEnv.config.set("asksAboutAppMove", 5)
      } else {
        NylasEnv.config.set("asksAboutAppMove", numAsks + 1)
      }
    } else {
      NylasEnv.config.set("asksAboutAppMove", numAsks + 1)
    }
  }
}

export function activate() {
  if (NylasEnv.inDevMode() || NylasEnv.inSpecMode()) { return; }

  if (process.platform !== "darwin") { return; }

  const appRe = /Applications/gi;
  if (appRe.test(process.argv[0])) { return; }

  // If we're in Volumes, that means we've launched from the DMG. This
  // is unsupported. We should optimistically move.
  const volTest = /Volumes/gi;
  if (volTest.test(process.argv[0])) {
    ipcRenderer.send("move-to-applications");
    return;
  }

  const numAsks = NylasEnv.config.get("asksAboutAppMove")
  if (numAsks >= 5) return;

  let buttons;
  if (numAsks >= 1) {
    buttons = [
      "Move to Applications folder",
      "Don't ask again",
      "Do not move",
    ]
  } else {
    buttons = [
      "Move to Applications folder",
      "Do not move",
    ]
  }

  const msg = `We recommend that you move N1 to your Applications folder to get updates correctly and keep this folder uncluttered.`

  const CANCEL_ID = 3;

  dialog.showMessageBox({
    type: "question",
    buttons: buttons,
    title: "A Better Place to Install N1",
    message: "Move to Applications folder?",
    detail: msg,
    defaultId: 0,
    cancelId: CANCEL_ID,
  }, onNotificationActionTaken(numAsks))
}

export function deactivate() {
}
{'fraction_non_alphanumeric': 0.12283575105287786, 'fraction_numerical': 0.006551240056153486, 'mean_word_length': 3.036827195467422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6075891', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1362, 'n_words': 424}