mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
implement electron-is-dev.
i love you @sindresorhus
This commit is contained in:
parent
db21e8e87d
commit
361f2c8fce
3 changed files with 18 additions and 5 deletions
21
index.js
21
index.js
|
|
@ -3,13 +3,24 @@ const createRPC = require('./rpc');
|
||||||
const Session = require('./session');
|
const Session = require('./session');
|
||||||
const genUid = require('uid2');
|
const genUid = require('uid2');
|
||||||
const { resolve } = require('path');
|
const { resolve } = require('path');
|
||||||
|
const isDev = require('electron-is-dev');
|
||||||
|
|
||||||
if ('development' === process.env.NODE_ENV) {
|
if (isDev) {
|
||||||
console.log('initializing in dev mode (NODE_ENV)');
|
console.log('running in dev mode');
|
||||||
} else {
|
} else {
|
||||||
console.log('initializing in prod mode (NODE_ENV)');
|
console.log('running in prod mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const url = 'file://' + resolve(
|
||||||
|
__dirname,
|
||||||
|
// in prod version, we copy over index.html and dist from 'app'
|
||||||
|
// into one dist folder to avoid unwanted files in package
|
||||||
|
isDev ? 'app' : '',
|
||||||
|
'index.html'
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('electron will open', url);
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
// by subscribing to this event and nooping
|
// by subscribing to this event and nooping
|
||||||
// we prevent electron's default behavior
|
// we prevent electron's default behavior
|
||||||
|
|
@ -28,10 +39,10 @@ app.on('ready', () => {
|
||||||
transparent: true,
|
transparent: true,
|
||||||
// we only want to show when the prompt
|
// we only want to show when the prompt
|
||||||
// is ready for user input
|
// is ready for user input
|
||||||
show: 'development' === process.env.NODE_ENV
|
show: isDev
|
||||||
});
|
});
|
||||||
|
|
||||||
win.loadURL('file://' + resolve(__dirname, 'app', 'index.html'));
|
win.loadURL(url);
|
||||||
|
|
||||||
const rpc = createRPC(win);
|
const rpc = createRPC(win);
|
||||||
const sessions = new Map();
|
const sessions = new Map();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"child_pty": "3.0.1",
|
||||||
|
"electron-is-dev": "0.1.1",
|
||||||
"electron-prebuilt": "1.2.5",
|
"electron-prebuilt": "1.2.5",
|
||||||
"uid2": "0.0.3",
|
"uid2": "0.0.3",
|
||||||
"child_pty": "3.0.1"
|
"child_pty": "3.0.1"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue