Skip to content

Commit

Permalink
Merge pull request #19 from MasicoreLord/app-compat
Browse files Browse the repository at this point in the history
Boost App Compatibility
  • Loading branch information
Kyza authored Jan 15, 2023
2 parents 3288843 + 76fafa3 commit 900e53a
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/main/startOriginal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,42 @@ const originalPackage = require(path.resolve(

const startPath = path.join(originalPath, originalPackage.main);

// Set app's version
if (originalPackage.version != null) {
// @ts-ignore
electron.app.setVersion(originalPackage.version)
}

// Set app's name
// Make sure the storage location doesn't change.
if (originalPackage.productName != null) {
electron.app.name = `${originalPackage.productName}`.trim();
} else if (originalPackage.name != null) {
electron.app.name = `${originalPackage.name}`.trim();
}

// Set app's desktop name
if (originalPackage.desktopName != null) {
// @ts-ignore
electron.app.setDesktopName(originalPackage.desktopName);
} else {
// @ts-ignore
electron.app.setDesktopName(`${electron.app.name}.desktop`);
}

// Set v8's flags
if (originalPackage.v8Flags != null) {
require('v8').setFlagsFromString(originalPackage.v8Flags);
}

// Don't corrupt the app on update.
require.main.filename = startPath;
// @ts-ignore
electron.app.setAppPath?.(originalPath);
// Make sure the storage location doesn't change.
electron.app.name = originalPackage.name;

// Load the app's original code.
// Run without import() to make sure it doesn't await in main process because that can be bad.
// Module._load(file, null, true) is used instead of require() because it lets you load the file as if it was the first file being run in the Node environment.
// Module._load(file, Module, true) is used instead of require() because it lets you load the file as if it was the first file being run in the Node environment.
// Using require could result in things breaking if the app ever uses require.main.
// @ts-ignore This does exist, it's just not typed.
Module._load(startPath, null, true);
Module._load(startPath, Module, true); // changed second arg to reference itself, as apparently electron itself would do it, not sure why, changed to increase compatibility

0 comments on commit 900e53a

Please sign in to comment.