<commit_before>import {
  app, BrowserWindow, ipcMain,
  Menu, Tray, session, crashReporter,
  autoUpdater, shell,
} from 'electron';
import path from 'path';
import fs from 'fs';
import childProcess from 'child_process';
import urlparse from 'url-parse';
import _ from 'underscore';
import LocalServer from './js/utils/localServer';
import { bindLocalServerEvent } from './js/utils/mainProcLocalServerEvents';

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
let trayMenu;
let closeConfirmed = false;
const version = app.getVersion();
const feedURL = `https://updates2.openbazaar.org:5001/update/${process.platform}/${version}`;
global.serverLog = '';

const handleStartupEvent = function () {
  if (process.platform !== 'win32') {
    return false;
  }

  const squirrelCommand = process.argv[1];

  function exeSquirrelCommand(args, cb) {
    const updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe');
    const child = childProcess.spawn(updateDotExe, args, { detached: true });
    child.on('close', cb());
  }

  function install(cb) {
    const target = path.basename(process.execPath);
    exeSquirrelCommand(['--createShortcut', target, ' --shortcut-locations=Desktop,StartMenu'], cb);
  }

  function uninstall(cb) {
    const target = path.basename(process.execPath);
    exeSquirrelCommand(['--removeShortcut', target], cb);
  }

  switch (squirrelCommand) {
    case '--squirrel-install':
      install(app.quit);
      break;

    case '--squirrel-updated':
      // Always quit when done
      app.quit();
      return true;

    case '--squirrel-uninstall':
      // Always quit when done
      uninstall(app.quit);
      return true;

    case '--squirrel-obsolete':
      // This is called on the outgoing version of your app before
      // we update to the new version - it's the opposite of
      // --squirrel-updated
      app.quit();
      return true;
    default:
      break;
  }

  return true;
};

if (handleStartupEvent()) {
  console.log('OpenBazaar started on Windows...');
}

const serverPath = `${__dirname}${path.sep}..${path.sep}OpenBazaar-Server${path.sep}`;
// const serverPath = `${__dirname}${path.sep}..${path.sep}test-server${path.sep}`;
const serverFilename = process.platform === 'darwin' || process.platform === 'linux' ?
      'openbazaard' : 'openbazaard.exe';
const isBundledApp = _.once(() => fs.existsSync(serverPath + path.sep + serverFilename));
global.isBundledApp = isBundledApp;
let localServer;

if (isBundledApp()) {
  global.localServer = localServer = new LocalServer({<commit_msg>removing debugging code<commit_after>import {
  app, BrowserWindow, ipcMain,
  Menu, Tray, session, crashReporter,
  autoUpdater, shell,
} from 'electron';
import path from 'path';
import fs from 'fs';
import childProcess from 'child_process';
import urlparse from 'url-parse';
import _ from 'underscore';
import LocalServer from './js/utils/localServer';
import { bindLocalServerEvent } from './js/utils/mainProcLocalServerEvents';

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
let trayMenu;
let closeConfirmed = false;
const version = app.getVersion();
const feedURL = `https://updates2.openbazaar.org:5001/update/${process.platform}/${version}`;
global.serverLog = '';

const handleStartupEvent = function () {
  if (process.platform !== 'win32') {
    return false;
  }

  const squirrelCommand = process.argv[1];

  function exeSquirrelCommand(args, cb) {
    const updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe');
    const child = childProcess.spawn(updateDotExe, args, { detached: true });
    child.on('close', cb());
  }

  function install(cb) {
    const target = path.basename(process.execPath);
    exeSquirrelCommand(['--createShortcut', target, ' --shortcut-locations=Desktop,StartMenu'], cb);
  }

  function uninstall(cb) {
    const target = path.basename(process.execPath);
    exeSquirrelCommand(['--removeShortcut', target], cb);
  }

  switch (squirrelCommand) {
    case '--squirrel-install':
      install(app.quit);
      break;

    case '--squirrel-updated':
      // Always quit when done
      app.quit();
      return true;

    case '--squirrel-uninstall':
      // Always quit when done
      uninstall(app.quit);
      return true;

    case '--squirrel-obsolete':
      // This is called on the outgoing version of your app before
      // we update to the new version - it's the opposite of
      // --squirrel-updated
      app.quit();
      return true;
    default:
      break;
  }

  return true;
};

if (handleStartupEvent()) {
  console.log('OpenBazaar started on Windows...');
}

const serverPath = `${__dirname}${path.sep}..${path.sep}OpenBazaar-Server${path.sep}`;
const serverFilename = process.platform === 'darwin' || process.platform === 'linux' ?
      'openbazaard' : 'openbazaard.exe';
const isBundledApp = _.once(() => fs.existsSync(serverPath + path.sep + serverFilename));
global.isBundledApp = isBundledApp;
let localServer;

if (isBundledApp()) {
  global.localServer = localServer = new LocalServer({
{'fraction_non_alphanumeric': 0.14016578749058026, 'fraction_numerical': 0.003014318010550113, 'mean_word_length': 3.765709156193896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '4562345', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1627, 'n_words': 420}