Created
March 26, 2018 02:52
-
-
Save drbh/5bb0b9d2e18c7945e080a685a7cf746d to your computer and use it in GitHub Desktop.
electron script for iMessage analyzer app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // main.js | |
| const rq = require('request-promise'); | |
| const electron = require('electron'); | |
| const app = electron.app; | |
| const BrowserWindow = electron.BrowserWindow; | |
| const child = require('child_process') | |
| var mainWindow = null; | |
| app.on('window-all-closed', function() { | |
| app.quit(); | |
| }); | |
| app.on('ready', function() { | |
| var subnode = child.spawn('/usr/local/bin/node', ['./server.js'], { | |
| cwd: process.cwd(), | |
| detached: false, | |
| stdio: "inherit" | |
| }) | |
| var mainAddr = 'http://localhost:5000/'; | |
| var openWindow = function() { | |
| mainWindow = new BrowserWindow({ width: 1500, height: 700, titleBarStyle: 'hidden' }); | |
| mainWindow.loadURL(mainAddr, { "extraHeaders": "pragma: no-cache\n" }); | |
| mainWindow.on('closed', function() { mainWindow = null; }); | |
| }; | |
| var startUp = function() { | |
| rq(mainAddr).then(function(htmlString) { | |
| console.log('server started!'); | |
| openWindow(); | |
| }).catch(function(err) { startUp(); }); | |
| }; | |
| startUp(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment