<commit_before>const { app, ipcMain, BrowserWindow } = require('electron')
const Menubar = require('menubar')
const electron = require('electron')
const path = require('path')
const url = require('url')
const fs = require('fs')

let baseRecipe = null
const allRecipes = 'recipes.json'
const windows = new Set()
const menubar = Menubar({
  width:300,
  height:400,
  icon: './images/kitchen-fork-icon.png'
})

menubar.on('ready', () => {
  console.log('READY?! OK!');
})

menubar.on('after-create-window', () => {
  menubar.window.loadURL(url.format({
    pathname: path.join(__dirname, '../index.html'),
    protocol: 'file:',
    slashes: true
    })
  )//.then(promise => () => {
  //
  //   return menubar.window.webContents.send('load', baseRecipe)
  // })
  // ipcMain.on('load', (event, arg) => {
  //   event.sender.send('load', baseRecipe)
  // })
  menubar.window.webContents.openDevTools();
})



const createGroceryList = exports.createGroceryList = (file) => {
  let groceryWindow = new BrowserWindow({show: false})
  windows.add(groceryWindow)

  groceryWindow.loadURL(url.format({
    pathname: path.join(__dirname, '../grocery-list.html'),
    protocol: 'file:',
    slashes: true
  }))

  groceryWindow.once('ready-to-show', () => {
    if (file) openFile(groceryWindow, file)
    groceryWindow.show()
  })

  return groceryWindow
}

const saveGroceryList = (content) => {
  let listName = dialog.showSaveDialog(groceryWindow, {
    title: 'Save Grocery List',
    defaultPath: menubar.getPath('documents'),
    filters: [
      { name: 'Grocery Lists', extensions: ['html'] }
    ]
  })

  if(!fileName) { return }
  fs.writeFileSync(fileName, content)
}

const path = require('path')
const url = require('url')
const menubar = Menubar({
  width:300,
  height:400,
  icon: './images/kitchen-fork-icon.png'
})

let mainWindow

menubar.on('ready', () => {
  console.log('READY!');
})

function createWindow () {
  mainWindow = new BrowserWindow({width: 800, height: 600})

  mainWindow.loadURL(url.format({
    pathname: path.join(__dirname, '../index.html'),
    protocol: 'file:',
    slashes: true
  }))

  mainWindow.webContents.openDevTools()

const saveRecipe = (data) => {
  if (!data) {return }
  writeRecipe(readRecipe(), data)
}

const readRecipe = () => {
  return JSON.parse(fs.readFileSync('recipes.json'))
}

const writeRecipe = (recipes, newRecipe) => {
  recipes.all_recipes.push(newRecipe)
  fs.writeFileSync('recipes.json', JSON.stringify(recipes, null, 2))
}

// Listen for load message from renderer process
ipcMain.on('load', (event, arg) => {
  //  Print response
    if (arg !== null) return
   else {
  //  Reply on load message from renderer process
    event.sender.send('load', fs.readFileSync('recipes.json'));
  }
});

ipcMain.on('currentRecipe', (event, data) => {
  saveRecipe(data)
})
<commit_msg>Removes extra event listener, unused createWindow() function, and extra variable declarations.<commit_after>const { app, ipcMain, BrowserWindow } = require('electron')
const Menubar = require('menubar')
const electron = require('electron')
const path = require('path')
const url = require('url')
const fs = require('fs')

let baseRecipe = null
const allRecipes = 'recipes.json'
const windows = new Set()
const menubar = Menubar({
  width:300,
  height:400,
  icon: './images/kitchen-fork-icon.png'
})

menubar.on('ready', () => {
  console.log('READY?! OK!');
})

menubar.on('after-create-window', () => {
  menubar.window.loadURL(url.format({
    pathname: path.join(__dirname, '../index.html'),
    protocol: 'file:',
    slashes: true
    })
  )//.then(promise => () => {
  //
  //   return menubar.window.webContents.send('load', baseRecipe)
  // })
  // ipcMain.on('load', (event, arg) => {
  //   event.sender.send('load', baseRecipe)
  // })
  menubar.window.webContents.openDevTools();
})

const createGroceryList = exports.createGroceryList = (file) => {
  let groceryWindow = new BrowserWindow({show: false})
  windows.add(groceryWindow)

  groceryWindow.loadURL(url.format({
    pathname: path.join(__dirname, '../grocery-list.html'),
    protocol: 'file:',
    slashes: true
  }))

  groceryWindow.once('ready-to-show', () => {
    if (file) openFile(groceryWindow, file)
    groceryWindow.show()
  })

  return groceryWindow
}

const saveGroceryList = (content) => {
  let listName = dialog.showSaveDialog(groceryWindow, {
    title: 'Save Grocery List',
    defaultPath: menubar.getPath('documents'),
    filters: [
      { name: 'Grocery Lists', extensions: ['html'] }
    ]
  })

  if(!fileName) { return }
  fs.writeFileSync(fileName, content)
}


let mainWindow

const saveRecipe = (data) => {
  if (!data) {return }
  writeRecipe(readRecipe(), data)
}

const readRecipe = () => {
  return JSON.parse(fs.readFileSync('recipes.json'))
}

const writeRecipe = (recipes, newRecipe) => {
  recipes.all_recipes.push(newRecipe)
  fs.writeFileSync('recipes.json', JSON.stringify(recipes, null, 2))
}

// Listen for load message from renderer process
ipcMain.on('load', (event, arg) => {
  //  Print response
    if (arg !== null) return
   else {
  //  Reply on load message from renderer process
    event.sender.send('load', fs.readFileSync('recipes.json'));
  }
});

ipcMain.on('currentRecipe', (event, data) => {
  saveRecipe(data)
})

{'fraction_non_alphanumeric': 0.1732476856225203, 'fraction_numerical': 0.0049121481201587006, 'mean_word_length': 3.9246511627906977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '1395692', 'n_tokens_mistral': 1870, 'n_tokens_neox': 1812, 'n_words': 362}