Updated some stuff

This commit is contained in:
WolverinDEV 2019-10-27 19:33:00 +01:00
parent a75a5a0fa3
commit 1864a19c63
4 changed files with 37 additions and 15 deletions

1
.gitignore vendored
View File

@ -19,3 +19,4 @@ updater/postzip/TeaClient-linux.tar.gz
!modules/renderer/imports/.copy_*.d.ts
package-lock.json
npm-debug.log

View File

@ -1,10 +1,7 @@
import * as electron from "electron";
import * as os from "os";
{
const app_path = electron.app.getAppPath();
console.log("Native module path: %s", app_path + "/native/build/" + os.platform() + "_" + os.arch() + "/");
}
import * as rhelper from "./modules/shared/require";
console.log("Native module path: %s", rhelper.native_module_path());
import * as crash_handler from "./modules/crash_handler";

View File

@ -1,3 +1,4 @@
require("../shared/require").setup_require(module);
import {app, BrowserWindow, remote} from "electron";
import * as path from "path";
import * as electron from "electron";
@ -72,16 +73,6 @@ export function handle_crash_callback(args: string[]) {
crash_window.focus();
});
}
module.paths.push(...(() => {
const app_path = (remote || electron).app.getAppPath();
const result = [];
result.push(app_path + "/native/build/" + os.platform() + "_" + os.arch() + "/");
if(app_path.endsWith(".asar"))
result.push(path.join(path.dirname(app_path), "natives"));
return result;
})());
export const handler = require( "teaclient_crash_handler");
export function initialize_handler(component_name: string, requires_file: boolean) {

33
modules/shared/require.ts Normal file
View File

@ -0,0 +1,33 @@
import {remote} from "electron";
import * as electron from "electron";
import * as os from "os";
import * as path from "path";
export function setup_require(module: NodeModule) {
module.paths.push(native_module_path());
}
export function native_module_path() {
const app_path = (remote || electron).app.getAppPath();
if(!app_path.endsWith(".asar")) {
if(os.platform() === "win32" && false) {
const win64 = process.env.hasOwnProperty('ProgramFiles(x86)');
return path.join(
app_path,
"native",
"build",
os.platform() + "_" + (win64 ? "x64" : "x86")
);
} else {
return path.join(
app_path,
"native",
"build",
os.platform() + "_" + os.arch()
);
}
} else {
return path.join(path.dirname(app_path), "natives");
}
}