<commit_before>'use strict';

const {app} = require('electron');
const prepareNext = require('electron-next');
const {is} = require('electron-util');
const log = require('electron-log');
const {autoUpdater} = require('electron-updater');
const toMilliseconds = require('@sindresorhus/to-milliseconds');

const {initializeTray} = require('./tray');
const plugins = require('./common/plugins');
const {initializeAnalytics} = require('./common/analytics');
const initializeExportList = require('./export-list');
const {openEditorWindow} = require('./editor');
const {track} = require('./common/analytics');
const {initializeGlobalAccelerators} = require('./global-accelerators');

require('./utils/sentry');

const filesToOpen = [];

app.on('open-file', (event, path) => {
  event.preventDefault();

  if (app.isReady()) {
    track('editor/opened/running');
    openEditorWindow(path);
  } else {
    filesToOpen.push(path);
  }
});

const initializePlugins = async () => {
  try {
    await plugins.prune();
    await plugins.upgrade();
  } catch (error) {
    console.log(error);
  }
};

const checkForUpdates = () => {
  if (is.development) {
    return false;
  }

  // For auto-update debugging in Console.app
  autoUpdater.logger = log;
  autoUpdater.logger.transports.file.level = 'info';

  setInterval(() => {
    autoUpdater.checkForUpdates();
  }, toMilliseconds({hours: 1}));

  autoUpdater.checkForUpdates();
};

// Prepare the renderer once the app is ready
(async () => {
  await app.whenReady();

  app.dock.hide();

  // Ensure all plugins are up to date
  initializePlugins();

  await prepareNext('./renderer');

  initializeAnalytics();
  initializeTray();
  initializeExportList();
  initializeGlobalAccelerators();

  for (const file of filesToOpen) {
    track('editor/opened/startup');
    openEditorWindow(file);
  }

  checkForUpdates();
})();

app.on('window-all-closed', event => event.preventDefault());<commit_msg>Open cropper window at app launch (#578)<commit_after>'use strict';

const {app} = require('electron');
const prepareNext = require('electron-next');
const {is} = require('electron-util');
const log = require('electron-log');
const {autoUpdater} = require('electron-updater');
const toMilliseconds = require('@sindresorhus/to-milliseconds');

const {initializeTray} = require('./tray');
const plugins = require('./common/plugins');
const {initializeAnalytics} = require('./common/analytics');
const initializeExportList = require('./export-list');
const {openCropperWindow} = require('./cropper');
const {openEditorWindow} = require('./editor');
const {track} = require('./common/analytics');
const {initializeGlobalAccelerators} = require('./global-accelerators');

require('./utils/sentry');

const filesToOpen = [];

app.on('open-file', (event, path) => {
  event.preventDefault();

  if (app.isReady()) {
    track('editor/opened/running');
    openEditorWindow(path);
  } else {
    filesToOpen.push(path);
  }
});

const initializePlugins = async () => {
  try {
    await plugins.prune();
    await plugins.upgrade();
  } catch (error) {
    console.log(error);
  }
};

const checkForUpdates = () => {
  if (is.development) {
    return false;
  }

  // For auto-update debugging in Console.app
  autoUpdater.logger = log;
  autoUpdater.logger.transports.file.level = 'info';

  setInterval(() => {
    autoUpdater.checkForUpdates();
  }, toMilliseconds({hours: 1}));

  autoUpdater.checkForUpdates();
};

// Prepare the renderer once the app is ready
(async () => {
  await app.whenReady();

  app.dock.hide();

  // Ensure all plugins are up to date
  initializePlugins();

  await prepareNext('./renderer');

  initializeAnalytics();
  initializeTray();
  initializeExportList();
  initializeGlobalAccelerators();

  for (const file of filesToOpen) {
    track('editor/opened/startup');
    openEditorWindow(file);
  }

  const {wasOpenedAtLogin} = app.getLoginItemSettings();
  const isOpeningFile = filesToOpen.length > 0;
  if (!isOpeningFile && !wasOpenedAtLogin) {
    openCropperWindow();
  }

  checkForUpdates();
})();

app.on('window-all-closed', event => event.preventDefault());
{'fraction_non_alphanumeric': 0.1702487321902922, 'fraction_numerical': 0.0014489253803429123, 'mean_word_length': 4.530040053404539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '3655404', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1273, 'n_words': 263}