feat(update): 实现多镜像源自更新机制 (update/upgrade) 并升级版本至 v0.2.1
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
This commit is contained in:
1 parent
6e73de697b
commit
2dfcf67b00
12 files changed
+1021
-9
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