Add runtime detection and unified mcp and probe CLI commands
This commit is contained in:
1 parent
551fb9177f
commit
b109f3f49f
8 files changed
+118
-19
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