This commit is contained in:
crusader 2018-10-02 21:43:26 +09:00
commit 389729aa02

View File

@ -3,7 +3,10 @@ import * as fse from 'fs-extra';
import * as path from 'path'; import * as path from 'path';
import * as ChildProcess from 'child_process'; import * as ChildProcess from 'child_process';
import { shellNeedsPatching, updateEnvironmentForProcess } from '@overflow/core/shell'; import {
shellNeedsPatching,
updateEnvironmentForProcess
} from '@overflow/core/shell';
import { parseAppURL } from '@overflow/core/parse-app-url'; import { parseAppURL } from '@overflow/core/parse-app-url';
// import { // import {
// enableSourceMaps, // enableSourceMaps,
@ -33,9 +36,8 @@ const launchTime = now();
let preventQuit = false; let preventQuit = false;
let readyTime: number | null = null; let readyTime: number | null = null;
let db: sqlite3.Database; let db: sqlite3.Database | null = null;
let probeProcess: ChildProcess.ChildProcess; let probeProcess: ChildProcess.ChildProcess | null = null;
type OnDidLoadFn = (window: AppWindow) => void; type OnDidLoadFn = (window: AppWindow) => void;
/** See the `onDidLoad` function. */ /** See the `onDidLoad` function. */
@ -167,7 +169,7 @@ function setAsDefaultProtocolClient(protocol: string) {
if (__WIN32__) { if (__WIN32__) {
app.setAsDefaultProtocolClient(protocol, process.execPath, [ app.setAsDefaultProtocolClient(protocol, process.execPath, [
'--protocol-launcher', '--protocol-launcher',
'--', '--'
]); ]);
} else { } else {
app.setAsDefaultProtocolClient(protocol); app.setAsDefaultProtocolClient(protocol);
@ -190,8 +192,6 @@ app.on('ready', () => {
? path.join(__dirname, '..', '..', 'config', '_database.sqlite') ? path.join(__dirname, '..', '..', 'config', '_database.sqlite')
: path.join(__dirname, '..', '..', 'bin', 'database.sqlite'); : path.join(__dirname, '..', '..', 'bin', 'database.sqlite');
db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => { db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => {
if (err) { if (err) {
console.error(err.message); console.error(err.message);
@ -228,9 +228,7 @@ app.on('ready', () => {
ipcMain.on( ipcMain.on(
'update-preferred-app-menu-item-labels', 'update-preferred-app-menu-item-labels',
( (event: Electron.IpcMessageEvent) => {
event: Electron.IpcMessageEvent,
) => {
menu = buildDefaultMenu(); menu = buildDefaultMenu();
Menu.setApplicationMenu(menu); Menu.setApplicationMenu(menu);
if (mainWindow) { if (mainWindow) {
@ -421,7 +419,6 @@ app.on('before-quit', function (event) {
if (null !== probeProcess && !probeProcess.killed) { if (null !== probeProcess && !probeProcess.killed) {
probeProcess.kill(); probeProcess.kill();
} }
}); });
// app.on( // app.on(
@ -440,14 +437,14 @@ function createWindow() {
if (__DEV__) { if (__DEV__) {
const { const {
default: installExtension, default: installExtension
} = require('electron-devtools-installer'); } = require('electron-devtools-installer');
require('electron-debug')({ showDevTools: true }); require('electron-debug')({ showDevTools: true });
const ChromeLens = { const ChromeLens = {
id: 'idikgljglpfilbhaboonnpnnincjhjkd', id: 'idikgljglpfilbhaboonnpnnincjhjkd',
electron: '>=1.2.1', electron: '>=1.2.1'
}; };
const extensions = [ChromeLens]; const extensions = [ChromeLens];
@ -473,7 +470,7 @@ function createWindow() {
window.sendLaunchTimingStats({ window.sendLaunchTimingStats({
mainReadyTime: readyTime ? readyTime : 0, mainReadyTime: readyTime ? readyTime : 0,
loadTime: window.loadTime ? window.loadTime : 0, loadTime: window.loadTime ? window.loadTime : 0,
rendererReadyTime: window.rendererReadyTime ? window.rendererReadyTime : 0, rendererReadyTime: window.rendererReadyTime ? window.rendererReadyTime : 0
}); });
const fns = onDidLoadFns ? onDidLoadFns : null; const fns = onDidLoadFns ? onDidLoadFns : null;