Skip to content

Commit

Permalink
show sharedown version in release package too
Browse files Browse the repository at this point in the history
  • Loading branch information
kylon committed Apr 2, 2023
1 parent f4676a2 commit 22fb0e2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
11 changes: 11 additions & 0 deletions buildHooks/afterAllArtifactBuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.default = function () {
const fs = require('fs');

try {
fs.unlinkSync('version.js');

} catch (err) {
console.error('Build: failed to delete version.js, ' + err);
}
}

11 changes: 11 additions & 0 deletions buildHooks/beforePack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.default = async function(context) {
const fs = require('fs');

try {
fs.writeFileSync('version.js', `const title = "${context.packager.appInfo.productName} ${context.packager.appInfo.version}"; module.exports = title;`);

} catch (err) {
console.error('Build: failed to write version.js, ' + err);
}
}

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"build": {
"appId": "com.electron.sharedown",
"copyright": "Copyright © 2023 kylon",
"beforePack": "buildHooks/beforePack.js",
"afterAllArtifactBuild": "buildHooks/afterAllArtifactBuild.js",
"mac": {
"category": "public.app-category.video",
"target": {
Expand Down
9 changes: 8 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,14 @@ const SharedownAPI = (() => {
}

api.getWindowTitle = () => {
return `${process.env.npm_package_name} ${process.env.npm_package_version}`;
try {
const titleStr = require('./version.js');

return titleStr;

} catch (e) {
return `${process.env.npm_package_name} ${process.env.npm_package_version}`;
}
}

api.showMessage = (dtype, msg, dtitle) => ipcRenderer.sendSync('showMessage', {type: dtype, m: msg, title: dtitle});
Expand Down

0 comments on commit 22fb0e2

Please sign in to comment.