mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
Electron: Fixed getting package info
This commit is contained in:
parent
1a610054d3
commit
fa22d5bae3
1
ElectronClient/.gitignore
vendored
1
ElectronClient/.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
app/node_modules/
|
||||
app/packageInfo.js
|
||||
dist/
|
||||
app/lib/
|
||||
app/gui/*.min.js
|
||||
|
@ -15,6 +15,7 @@ const { JoplinDatabase } = require('lib/joplin-database.js');
|
||||
const { DatabaseDriverNode } = require('lib/database-driver-node.js');
|
||||
const { ElectronAppWrapper } = require('./ElectronAppWrapper');
|
||||
const { defaultState } = require('lib/reducer.js');
|
||||
const packageInfo = require('./packageInfo.js');
|
||||
const AlarmService = require('lib/services/AlarmService.js');
|
||||
const AlarmServiceDriverNode = require('lib/services/AlarmServiceDriverNode');
|
||||
|
||||
@ -274,7 +275,7 @@ class Application extends BaseApplication {
|
||||
}, {
|
||||
label: _('About Joplin'),
|
||||
click: () => {
|
||||
const p = this.packageInfo();
|
||||
const p = packageInfo;
|
||||
let message = [
|
||||
p.description,
|
||||
'',
|
||||
@ -308,16 +309,10 @@ class Application extends BaseApplication {
|
||||
this.lastMenuScreen_ = screen;
|
||||
}
|
||||
|
||||
packageInfo() {
|
||||
if (this.packageInfo_) return this.packageInfo_;
|
||||
this.packageInfo_ = require('./package.json');
|
||||
return this.packageInfo_;
|
||||
}
|
||||
|
||||
async start(argv) {
|
||||
argv = await super.start(argv);
|
||||
|
||||
AlarmService.setDriver(new AlarmServiceDriverNode({ appName: this.packageInfo().build.appId }));
|
||||
AlarmService.setDriver(new AlarmServiceDriverNode({ appName: packageInfo.build.appId }));
|
||||
AlarmService.setLogger(reg.logger());
|
||||
|
||||
if (Setting.value('openDevTools')) {
|
||||
|
23
ElectronClient/app/compile-package-info.js
Normal file
23
ElectronClient/app/compile-package-info.js
Normal file
@ -0,0 +1,23 @@
|
||||
const fs = require('fs-extra');
|
||||
|
||||
// Electron Builder strip off certain important keys from package.json, which we need, in particular build.appId
|
||||
// so this script is used to preserve the keys that we need.
|
||||
|
||||
const packageInfo = require(__dirname + '/package.json');
|
||||
|
||||
let removeKeys = ['scripts', 'devDependencies', 'optionalDependencies', 'dependencies'];
|
||||
|
||||
for (let i = 0; i < removeKeys.length; i++) {
|
||||
delete packageInfo[removeKeys[i]];
|
||||
}
|
||||
|
||||
const appId = packageInfo.build.appId;
|
||||
|
||||
delete packageInfo.build;
|
||||
packageInfo.build = { appId: appId };
|
||||
|
||||
let fileContent = "// Auto-generated by compile-package-info.js\n// Do not change directly\nconst packageInfo = " + JSON.stringify(packageInfo, null, 4) + ';';
|
||||
fileContent += "\n";
|
||||
fileContent += "module.exports = packageInfo;";
|
||||
|
||||
fs.writeFileSync(__dirname + '/packageInfo.js', fileContent);
|
@ -49,6 +49,11 @@ shimInit();
|
||||
app().start(bridge().processArgv()).then(() => {
|
||||
require('./gui/Root.min.js');
|
||||
}).catch((error) => {
|
||||
console.error('Fatal error:');
|
||||
console.error(error);
|
||||
// If something goes wrong at this stage we don't have a console or a log file
|
||||
// so display the error in a message box.
|
||||
let msg = ['Fatal error:', error.message];
|
||||
if (error.fileName) msg.push(error.fileName);
|
||||
if (error.lineNumber) msg.push(error.lineNumber);
|
||||
if (error.stack) msg.push(error.stack);
|
||||
bridge().showErrorMessageBox(msg.join('\n'));
|
||||
});
|
@ -8,8 +8,8 @@
|
||||
"pack": "node_modules/.bin/electron-builder --dir",
|
||||
"dist": "node_modules/.bin/electron-builder",
|
||||
"publish": "build -p always",
|
||||
"postinstall": "node compile-jsx.js",
|
||||
"compile": "node compile-jsx.js"
|
||||
"postinstall": "node compile-jsx.js && node compile-package-info.js",
|
||||
"compile": "node compile-jsx.js && node compile-package-info.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
Loading…
Reference in New Issue
Block a user