-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a35836
commit 22dcd97
Showing
6 changed files
with
244 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Based on https://github.com/electron/electron-quick-start | ||
|
||
const { app, BrowserWindow } = require('electron') | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
|
||
let mainWindow; | ||
|
||
function createWindow () { | ||
mainWindow = new BrowserWindow({ | ||
width: 800, | ||
height: 600, | ||
webPreferences: { | ||
nodeIntegration: false, | ||
contextIsolation: true, | ||
sandbox: true, | ||
webSecurity: true | ||
} | ||
}) | ||
|
||
// mainWindow.loadFile('index.html') | ||
mainWindow.loadURL('http://localhost:'+ (argv.port? argv.port: 8000) ); | ||
|
||
// Open the DevTools. | ||
// mainWindow.webContents.openDevTools() | ||
|
||
mainWindow.on('closed', function () { | ||
// Dereference the window object, usually you would store windows | ||
// in an array if your app supports multi windows, this is the time | ||
// when you should delete the corresponding element. | ||
mainWindow = null | ||
}) | ||
} | ||
|
||
app.on('ready', createWindow) | ||
|
||
app.on('window-all-closed', function () { | ||
// On macOS it is common for applications and their menu bar | ||
// to stay active until the user quits explicitly with Cmd + Q | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}) | ||
|
||
app.on('activate', function () { | ||
// On macOS it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
if (mainWindow === null) { | ||
createWindow() | ||
} | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"private": true, | ||
"name": "redux-devtools-cli", | ||
"version": "0.0.1", | ||
"main": "electron.js", | ||
"description": "Remote Redux DevTools", | ||
"authors": "Mihail Diordiev" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
var opn = require('opn'); | ||
var path = require('path'); | ||
var spawn = require('cross-spawn'); | ||
|
||
function open(app, options) { | ||
console.log('app', app) | ||
opn('http://localhost:' + options.port + '/', app !== 'browser' && app !== true ? { app: app } : undefined); | ||
if (app === true || app === 'electron') { | ||
try { | ||
spawn.sync( | ||
require('electron'), | ||
[path.join(__dirname, '..', 'app')] | ||
); | ||
} catch (error) { | ||
if (error.message === 'Cannot find module \'electron\'') { | ||
// TODO: Move electron to dev-dependences to make our package installation faster when not needed. | ||
console.log(' \x1b[1;31m[Warn]\x1b[0m Electron module not installed.\n'); | ||
/* | ||
We will use "npm" to install Electron via "npm install -D". | ||
Do you want to install 'electron' (yes/no): yes | ||
Installing 'electron' (running 'npm install -D webpack-cli')... | ||
*/ | ||
} else { | ||
console.log(error); | ||
} | ||
} | ||
return; | ||
} | ||
opn('http://localhost:' + options.port + '/', app !== 'browser' ? { app: app } : undefined); | ||
} | ||
|
||
module.exports = open; |
This file contains 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
Oops, something went wrong.