diff --git a/index.js b/index.js index e61e00929..d6383695a 100755 --- a/index.js +++ b/index.js @@ -28,10 +28,6 @@ var installStatsIndex = require('./src/main/osm-stats') var TileImporter = require('./src/main/tile-importer') var locale = require('./src/main/locale') -if (require('electron-squirrel-startup')) { - process.exit(0) -} - // HACK: enable GPU graphics acceleration on some older laptops app.commandLine.appendSwitch('ignore-gpu-blacklist', 'true') @@ -42,20 +38,19 @@ var log = null var win = null var splash = null -var shouldQuit = app.makeSingleInstance(function ( - commandLine, - workingDirectory -) { - // Someone tried to run a second instance, we should focus our window. - if (win) { - if (win.isMinimized()) win.restore() - win.focus() - } -}) +var gotTheLock = app.requestSingleInstanceLock() -if (shouldQuit) { - app.quit() +if (!gotTheLock) { + // Didn't get a lock, because another instance is open, so we quit process.exit(0) +} else { + app.on('second-instance', () => { + // Someone tried to run a second instance, we should focus our window. + if (win) { + if (win.isMinimized()) win.restore() + win.focus() + } + }) } // Path to `userData`, operating system specific, see @@ -101,7 +96,10 @@ function openWindow () { show: false, alwaysOnTop: false, titleBarStyle: 'hidden', - icon: path.resolve(__dirname, 'static', 'mapeo_256x256.png') + icon: path.resolve(__dirname, 'static', 'mapeo_256x256.png'), + webPreferences: { + nodeIntegration: true + } }) splash = new BrowserWindow({ width: 810, diff --git a/package.json b/package.json index 044851965..efba21b42 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "inherits": "^2.0.3", "insert-css": "^1.0.0", "lodash": "^4.17.4", - "mapeo-server": "^16.0.0", + "mapeo-server": "^16.1.1", "mapeo-styles": "^3.0.0", "minimist": "^1.2.0", "mirror-folder": "^2.1.1", @@ -137,8 +137,8 @@ "cross-spawn": "^4.0.2", "css-loader": "^3.2.0", "devtron": "^1.2.0", - "electron": "^2.0.7", - "electron-builder": "^20.8.1", + "electron": "^6.0.10", + "electron-builder": "^21.2.0", "electron-devtools-installer": "^2.2.4", "electron-rebuild": "^1.8.6", "eslint": "^6.4.0", @@ -149,7 +149,7 @@ "hubfs.js": "^1.0.0", "license-check": "^1.1.5", "mock-data": "^1.5.5", - "npm-platform-dependencies": "0.0.12", + "npm-platform-dependencies": "^0.1.0", "patch-package": "^6.2.0", "pngjs": "^3.3.3", "spectron": "^4.0.0", @@ -160,7 +160,7 @@ "tape": "^4.9.1", "watchify": "^3.7.0", "webpack": "^4.40.2", - "webpack-cli": "^3.3.8", + "webpack-cli": "^3.3.9", "webpack-livereload-plugin": "^2.2.0", "webpack-node-externals": "^1.7.2" },