refactor(core,packaging): relocate embedded assets and binary runtime to src/packaging and enforce core whitelist
This commit is contained in:
1 parent
3864f0ffd0
commit
27c86e052a
10 files changed
+20
-5
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export function isCompiledBinary(execPath = process.execPath, metaUrl = import.meta.url): boolean {
|
||||
if (metaUrl.includes("/$bunfs/") || metaUrl.includes("\\$bunfs\\")) {
|
||||
return true;
|
||||
}
|
||||
const lower = execPath.toLowerCase().replace(/\\/g, "/");
|
||||
return !lower.endsWith("/bun") && !lower.endsWith("/bun.exe");
|
||||
}
|
||||
|
||||
export function resolveAppRoot(entryFile?: string, isCompiled = isCompiledBinary()): string {
|
||||
if (isCompiled) {
|
||||
return process.cwd();
|
||||
}
|
||||
const file = entryFile || fileURLToPath(import.meta.url);
|
||||
return dirname(dirname(file));
|
||||
}
|
||||
|
||||
export type LauncherConfig = {
|
||||
command: string;
|
||||
args?: string[];
|
||||
};
|
||||
|
||||
export function resolveDefaultLauncher(
|
||||
entryFile: string,
|
||||
isCompiled = isCompiledBinary(),
|
||||
execPath = process.execPath
|
||||
): LauncherConfig {
|
||||
if (isCompiled) {
|
||||
return {
|
||||
command: execPath,
|
||||
args: [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
command: execPath,
|
||||
args: [entryFile],
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user