mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-12 07:12:54 +01:00
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>
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
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/");
|
|
}
|