UNPKG

1.36 kBJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10const {app, BrowserWindow} = require('electron'); // Module to create native browser window.
11const {join} = require('path');
12
13const argv = require('minimist')(process.argv.slice(2));
14const projectRoots = argv._;
15
16let mainWindow = null;
17
18app.on('window-all-closed', function() {
19 app.quit();
20});
21
22app.on('ready', function() {
23 // Create the browser window.
24 mainWindow = new BrowserWindow({
25 width: 800,
26 height: 600,
27 icon: join(__dirname, 'icons/icon128.png'),
28 frame: false,
29 //titleBarStyle: 'customButtonsOnHover',
30 webPreferences: {
31 nodeIntegration: true,
32 },
33 });
34
35 // and load the index.html of the app.
36 mainWindow.loadURL('file://' + __dirname + '/app.html'); // eslint-disable-line no-path-concat
37 mainWindow.webContents.executeJavaScript(
38 // We use this so that RN can keep relative JSX __source filenames
39 // but "click to open in editor" still works. js1 passes project roots
40 // as the argument to DevTools.
41 'window.devtools.setProjectRoots(' + JSON.stringify(projectRoots) + ')',
42 );
43
44 // Emitted when the window is closed.
45 mainWindow.on('closed', function() {
46 mainWindow = null;
47 });
48});