<commit_before>var app = require('app'),
  BrowserWindow = require('browser-window'),
  ipc = require('ipc'),
  Menu = require('menu'),
  dialog = require('dialog'),
  config = {},
  fs = require('fs')
  path = require('path');

// report crashes to atom-shell
require('crash-reporter').start();

//------------------------------------------------------------------------------
// Dialogs
// (These have to be created on the "browser" side, i.e. here, not on the "page")
//------------------------------------------------------------------------------

function showAddExistingProjectDialog() {
  var options = {
    title: "Select an existing project (project.clj)",
    properties: ["openFile"],
    filters: [
      {
        name: "Leiningen project config",
        extensions: ["clj"]
      }
    ]
  };

  dialog.showOpenDialog(options, function(filenames) {
    if (filenames) {
      var filename = filenames[0];
      mainWindow.webContents.send("add-existing-project-dialog-success", filename);
    }
  });
}

ipc.on("request-add-existing-project-dialog", function(event, arg) {
  showAddExistingProjectDialog();
});

//------------------------------------------------------------------------------
// Menu Builder
//------------------------------------------------------------------------------

var menuTemplate = [
  {
    label: "File", // NOTE: On Mac, the first menu item is always the name of the Application
                   //       (uses CFBundleName in Info.plist, set by "release.sh")
    submenu: [
      {
        label: "Add Existing Project",
        click: showAddExistingProjectDialog
      }
    ]
  }
];

var menu = Menu.buildFromTemplate(menuTemplate);

// FIXME: custom menu disabled, since CMD+Q doesn't work without the menu item for it
// Menu.setApplicationMenu(menu);

//------------------------------------------------------------------------------
// Main
//------------------------------------------------------------------------------

// load config
// NOTE: this is mostly for development purposes
if (fs.existsSync(__dirname + '/config.json')) {
  config = require(__dirname + '/config.json');
}

// load window information
const windowInformationFile = app.getDataPath() + path.sep + 'window.json';
var windowInformation = {};
if (fs.existsSync(windowInformationFile)) {
  windowInformation = require(windowInformationFile);
}

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

var bounceID;

function onStartBounce() {
  // run bounce and set to bounceID
  bounceID = app.dock.bounce("critical");
  console.log(bounceID);

  // test code to see houw setBadge works
  app.dock.setBadge("E");
}

// ipc.on('start-bounce', onStartBounce);

function onStopBounce() {
  // need to get bounceID as returned from app.dock.bounce() and pass to
  // app.dock.cancelBounce(id)
  app.dock.cancelBounce(0);
}

// ipc.on('stop-bounce', onStopBounce);

// NOTE: so the docs say to only use this when the page has crashed, but I think
// it's ok in this case because of the way we're "trapping" the regular close event
// https://github.com/atom/atom-shell/blob/master/docs/api/browser-window.md#browserwindowdestroy

function shutdownForReal() {
  // save current window information
  windowInformation.maximized = mainWindow.isMaximized();
  windowInformation.position = mainWindow.getPosition();
  windowInformation.size = mainWindow.getSize();
  fs.writeFileSync(windowInformationFile, JSON.stringify(windowInformation));

  // NOTE: so the docs say to only use this when the page has crashed, but I think
  // it's ok in this case because of the way we're "trapping" the regular close event
  // https://github.com/atom/atom-shell/blob/master/docs/api/browser-window.md#browserwindowdestroy
  // TODO: look into using app.quit() here instead
  mainWindow.destroy();
}
<commit_msg>Github Issue #14<commit_after>var app = require('app'),
  BrowserWindow = require('browser-window'),
  ipc = require('ipc'),
  Menu = require('menu'),
  dialog = require('dialog'),
  config = {},
  fs = require('fs')
  path = require('path');

// report crashes to atom-shell
require('crash-reporter').start();

//------------------------------------------------------------------------------
// Dialogs
// (These have to be created on the "browser" side, i.e. here, not on the "page")
//------------------------------------------------------------------------------

function showAddExistingProjectDialog() {
  var options = {
    title: "Select an existing project (project.clj)",
    properties: ["openFile"],
    filters: [
      {
        name: "Leiningen project config",
        extensions: ["clj"]
      }
    ]
  };

  dialog.showOpenDialog(options, function(filenames) {
    if (filenames) {
      var filename = filenames[0];
      mainWindow.webContents.send("add-existing-project-dialog-success", filename);
    }
  });
}

ipc.on("request-add-existing-project-dialog", function(event, arg) {
  showAddExistingProjectDialog();
});

//------------------------------------------------------------------------------
// Menu Builder
//------------------------------------------------------------------------------

var menuTemplate = [
  {
    label: "File", // NOTE: On Mac, the first menu item is always the name of the Application
                   //       (uses CFBundleName in Info.plist, set by "release.sh")
    submenu: [
      {
        label: "Add Existing Project",
        click: showAddExistingProjectDialog
      }
    ]
  }
];

var menu = Menu.buildFromTemplate(menuTemplate);

// FIXME: custom menu disabled, since CMD+Q doesn't work without the menu item for it
// Menu.setApplicationMenu(menu);

//------------------------------------------------------------------------------
// Main
//------------------------------------------------------------------------------

// load config
// NOTE: this is mostly for development purposes
if (fs.existsSync(__dirname + '/config.json')) {
  config = require(__dirname + '/config.json');
}

// load window information
const windowInformationFile = app.getDataPath() + path.sep + 'window.json';
var windowInformation = {};
if (fs.existsSync(windowInformationFile)) {
  windowInformation = require(windowInformationFile);
}

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

var bounceID;

function onStartBounce() {
  // run bounce and set to bounceID
  bounceID = app.dock.bounce("critical");
  console.log(bounceID);

  // test code to see how setBadge works
  app.dock.setBadge("E");
}

// ipc.on('start-bounce', onStartBounce);

function onStopBounce() {
  // need to get bounceID as returned from app.dock.bounce() and pass to
  // app.dock.cancelBounce(id)
  app.dock.cancelBounce(0);
}

// ipc.on('stop-bounce', onStopBounce);

// NOTE: so the docs say to only use this when the page has crashed, but I think
// it's ok in this case because of the way we're "trapping" the regular close event
// https://github.com/atom/atom-shell/blob/master/docs/api/browser-window.md#browserwindowdestroy

function shutdownForReal() {
  // save current window information
  windowInformation.maximized = mainWindow.isMaximized();
  windowInformation.position = mainWindow.getPosition();
  windowInformation.size = mainWindow.getSize();
  fs.writeFileSync(windowInformationFile, JSON.stringify(windowInformation));

  // NOTE: so the docs say to only use this when the page has crashed, but I think
  // it's ok in this case because of the way we're "trapping" the regular close event
  // https://github.com/atom/atom-shell/blob/master/docs/api/browser-window.md#browserwindowdestroy
  // TODO: look into using app.quit() here instead
  mainWindow.destroy();
}

{'fraction_non_alphanumeric': 0.2341209349593496, 'fraction_numerical': 0.0007621951219512195, 'mean_word_length': 2.1784416633023818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '2578395', 'n_tokens_mistral': 2143, 'n_tokens_neox': 2086, 'n_words': 612}