-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
81 lines (65 loc) · 2.12 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// @ts-nocheck
const { app, BrowserWindow } = require('electron');
const packageJson = require('./package.json');
const fs = require("fs");
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
width: 860,
height: 680,
resizable: false,
webPreferences: {
nodeIntegration: true
}
});
fs.readFile('app/index.html', 'utf8', function (err, data) {
if (err) throw err;
// Disable dev tools
mainWindow.webContents.closeDevTools();
// Remove the menu bar
mainWindow.setMenu(null);
// Set menu bar visibility to false
mainWindow.setMenuBarVisibility(false);
mainWindow.on('closed', function () {
mainWindow = null
});
// find the span element with the id "version" and update its text content
const updatedData = data.replace(/<span id="version">.*<\/span>/, `<span id="version">${packageJson.version}</span>`);
// write the updated index.html file
fs.writeFileSync('app/index.html', updatedData, function (err) {
if (err) throw err;
console.log('Version number updated in index.html');
});
// Load the updated index.html file
mainWindow.loadFile('app/index.html');
});
}
app.on('ready', createWindow);
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', function () {
if (mainWindow === null) createWindow();
});
app.on('browser-window-created', (event, window) => {
// Disable dev tools
window.webContents.closeDevTools();
// Remove the menu bar
window.setMenu(null);
// Set menu bar visibility to false
window.setMenuBarVisibility(false);
});
// update the version number in the package.json file
packageJson.version = process.env.npm_package_version;
// write the updated packageJson object to the package.json file
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), function (err) {
if (err) throw err;
console.log('Version number updated in package.json');
});
(function () {
async function myFunction() {
const forgeConfig = await import('forge.config.cjs');
// use forgeConfig here
}
myFunction();
})();