<commit_before>import {BrowserWindow} from 'electron';
import path from 'path';
import url from 'url';

import handleBeforeSendHeaders from './events/handleBeforeSendHeaders';


// 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 main, preloader

const createWindow = () => {
    createPreloaderWindow();
    createMainWindow();

    // Display UI when bundled and ready
    main.once('ready-to-show', () => {
        main.show();
        main.setFullScreen(true);
        preloader.close();

        if (config.env.development)
            main.webContents.openDevTools('right');
    });
}

export default createWindow

function createPreloaderWindow(opts) {
    if (preloader)
       return preloader

    preloader = new BrowserWindow(config.electron.preloader)


    if (process.env.NODE_ENV === "development") {
        preloader.loadURL(url.format({
            pathname: path.join(__dirname, 'dev', `preloader.html`),
            protocol: 'file:',
            slashes: true
        }));
    } else {
        preloader.loadURL(url.format({
            pathname: path.join(__dirname, "preloader.html"),
            protocol: 'file:',
            slashes: true
        }));
    }

    preloader.on('closed', () => {
        preloader = null
    });
}

function createMainWindow(opts) {
    if (main)
        return main

    main = new BrowserWindow(config.electron.main)

    // Set custom headers to bypass 4chan image block
    main.webContents.session.webRequest.onBeforeSendHeaders(handleBeforeSendHeaders);

    if (process.env.NODE_ENV === "development") {
        // Allow dynamic webpack content serving
        // main.__WebpackUrl__ = config.server.url + "app.bundle.js"
        main.loadURL(url.format({
            pathname: path.join(__dirname, 'dev', 'index.html'),
            protocol: 'file:',
            slashes: true
        }));
    } else {
        main.loadURL(url.format({
            pathname: path.join(__dirname, 'index.html'),
            protocol: 'file:',
            slashes: true
        }));
    }

    main.on('closed', () => {
        main = null
    });
}<commit_msg>feat(electron): Update node_env filepath handling<commit_after>import {BrowserWindow} from 'electron';
import path from 'path';
import url from 'url';

import handleBeforeSendHeaders from './events/handleBeforeSendHeaders';
import handleRedirect from './events/handleRedirect';


// 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 main, preloader

export default function createWindow () {
    createPreloaderWindow();
    createMainWindow();

    // Display UI when bundled and ready
    main.once('ready-to-show', () => {
        main.show();
        main.setFullScreen(true);
        preloader.close();

        if (config.env.development)
            main.webContents.openDevTools('right');
    });
}

function createPreloaderWindow(opts) {
    if (preloader)
       return preloader

    preloader = new BrowserWindow(config.electron.preloader)

    var preloaderPath;

    if (process.env.NODE_ENV === "development") {
        preloaderPath = path.join(__dirname, 'dev', `preloader.html`)
    } else {
        preloaderPath = path.join(__dirname, "preloader.html")
    }

    preloader.loadURL(url.format({
        pathname: preloaderPath,
        protocol: 'file:',
        slashes: true
    }));

    preloader.on('closed', () => {
        preloader = null
    });
}

function createMainWindow(opts) {
    if (main)
        return main

    main = new BrowserWindow(config.electron.main)

    // Set custom headers to bypass 4chan image block
    main.webContents.session.webRequest.onBeforeSendHeaders(handleBeforeSendHeaders);

    // Open links in browser
    main.webContents.on('new-window', handleRedirect)

    var indexPath;

    if (process.env.NODE_ENV === "development") {
        indexPath = path.join(__dirname, 'dev', 'index.html')
    } else {
        indexPath = path.join(__dirname, 'index.html')
    }

    main.loadURL(url.format({
        pathname: indexPath,
        protocol: 'file:',
        slashes: true
    }));

    main.on('closed', () => {
        main = null
    });
}
{'fraction_non_alphanumeric': 0.12448036951501154, 'fraction_numerical': 0.00046189376443418013, 'mean_word_length': 2.630343671416597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '4651502', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1224, 'n_words': 295}