mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 12:22:14 +03:00
Integrated into release/v3.8.0 — batch of 10 feature requests: llama.cpp local provider, upstream error exposure, Termux detection, providers rotate CLI, t3.chat web skeleton, Zed Docker integration, Kiro multi-account OAuth isolation, auto-combo cost blending, auto-combo context filter, combo provider-level exhaustion tracking (#1731). Conflicts with #2417 (falloverBeforeRetry) resolved.
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { existsSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
/**
|
|
* Detect whether the current install tree contains the published standalone app bundle.
|
|
* Source checkouts should not create `app/` during postinstall because Next.js would
|
|
* mis-detect it as a competing App Router root and serve 404s for the real `src/app` routes.
|
|
*
|
|
* @param {string} rootDir
|
|
* @returns {boolean}
|
|
*/
|
|
export function hasStandaloneAppBundle(rootDir) {
|
|
return existsSync(join(rootDir, "app", "server.js"));
|
|
}
|
|
|
|
/**
|
|
* Returns true when running inside a Termux environment on Android.
|
|
*
|
|
* Node.js on Termux reports process.platform === "linux" (not "android"),
|
|
* so OS-level platform checks are insufficient. Use Termux-specific signals:
|
|
* 1. TERMUX_VERSION env var (set by Termux bootstrap, most reliable)
|
|
* 2. PREFIX env var containing "com.termux"
|
|
* 3. Filesystem probe at /data/data/com.termux (last resort, no env needed)
|
|
*
|
|
* @param {object} [env] Override process.env for testing.
|
|
* @returns {boolean}
|
|
*/
|
|
export function isTermux(env = process.env) {
|
|
if (env.TERMUX_VERSION) return true;
|
|
if (typeof env.PREFIX === "string" && env.PREFIX.includes("com.termux")) return true;
|
|
try {
|
|
return existsSync("/data/data/com.termux");
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|