Add --config-file=FILE
option for testing
This commit is contained in:
@@ -12,8 +12,9 @@ var contextMenu = require('./menus/context');
|
|||||||
var webView = document.getElementById('mainWebview');
|
var webView = document.getElementById('mainWebview');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var configFile = electron.remote.app.getPath('userData') + '/config.json';
|
var configFile = remote.getGlobal('config-file');
|
||||||
var config = require(configFile);
|
var str = fs.readFileSync(configFile);
|
||||||
|
var config = JSON.parse(str);
|
||||||
if (config.url) {
|
if (config.url) {
|
||||||
webView.setAttribute('src', config.url);
|
webView.setAttribute('src', config.url);
|
||||||
}
|
}
|
||||||
|
11
src/main.js
11
src/main.js
@@ -10,14 +10,23 @@ const fs = require('fs');
|
|||||||
|
|
||||||
var appMenu = require('./menus/app');
|
var appMenu = require('./menus/app');
|
||||||
|
|
||||||
|
var argv = require('yargs').argv;
|
||||||
|
|
||||||
var client = null;
|
var client = null;
|
||||||
if (process.argv.indexOf('--livereload') > 0) {
|
if (argv.livereload) {
|
||||||
client = require('electron-connect').client.create();
|
client = require('electron-connect').client.create();
|
||||||
client.on('stop', function() {
|
client.on('stop', function() {
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv['config-file']) {
|
||||||
|
global['config-file'] = argv['config-file'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
global['config-file'] = app.getPath('userData') + '/config.json'
|
||||||
|
}
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
var mainWindow = null;
|
var mainWindow = null;
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
"electron-connect": "^0.3.3"
|
"electron-connect": "^0.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"os-locale": "^1.4.0"
|
"os-locale": "^1.4.0",
|
||||||
|
"yargs": "^3.31.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
var saveSettings = function() {
|
var saveSettings = function() {
|
||||||
var configFile = remote.app.getPath('userData') + '/config.json';
|
var configFile = remote.getGlobal('config-file');
|
||||||
var urlInput = document.getElementById('url');
|
var urlInput = document.getElementById('url');
|
||||||
var config = {
|
var config = {
|
||||||
url: urlInput.value
|
url: urlInput.value
|
||||||
|
Reference in New Issue
Block a user