Initial commit

Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com>
Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com>
Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com>
Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com>
Co-Authored-By: Johan  <4934465+joolsus@users.noreply.github.com>
Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com>
Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
This commit is contained in:
Michael Cartner
2024-01-26 11:52:55 +01:00
commit b9c60b07dc
2789 changed files with 868795 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
import path from "path";
import { getDesktopTrampolinePath as desktopGetDesktopTrampolinePath } from "desktop-trampoline";
let cache_desktopTrampolinePath: string = null;
/**
* Returns and caches the desktop trampoline path,
* via "desktop-trampoline"'s helper method.
*
* @returns
*/
function getDesktopTrampolinePathHelper() {
if (cache_desktopTrampolinePath !== null) return cache_desktopTrampolinePath;
// getDesktopTrampolinePath takes about 5ms, caching it removes the time.
cache_desktopTrampolinePath = desktopGetDesktopTrampolinePath();
//this is required due to this limitation in electron: https://github.com/electron/electron/issues/8206
//only affects production builds
cache_desktopTrampolinePath = cache_desktopTrampolinePath.replace(
"asar",
"asar.unpacked"
);
return cache_desktopTrampolinePath;
}
/**
* Returns the desktop trampoline path, where we expect it to be.
*
* @returns
*/
export function getDesktopTrampolinePath(): string {
if (process.env.LOCAL_GIT_TRAMPOLINE_DIRECTORY) {
return process.env.LOCAL_GIT_TRAMPOLINE_DIRECTORY;
}
return path
.resolve(
__dirname,
"..",
"..",
"node_modules",
"desktop-trampoline",
"build",
"Release",
"desktop-trampoline"
)
.replace(/[\\\/]app.asar[\\\/]/, "/app.asar.unpacked/");
}
export function getGitPath(): string {
// This is required because dugite is not imported as external package.
// Where __dirname would otherwise be the package path.
return path
.resolve(__dirname, "..", "..", "node_modules", "dugite", "git")
.replace(/[\\\/]app.asar[\\\/]/, "/app.asar.unpacked/");
}