@oh-my-pi/pi-utils 14.9.7 → 14.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/env.ts +14 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "14.9.7",
4
+ "version": "14.9.9",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/bun": "^1.3.13",
41
- "@oh-my-pi/pi-natives": "14.9.7"
41
+ "@oh-my-pi/pi-natives": "14.9.9"
42
42
  },
43
43
  "engines": {
44
44
  "bun": ">=1.3.7"
package/src/env.ts CHANGED
@@ -100,6 +100,20 @@ export function isBunTestRuntime(): boolean {
100
100
  return Bun.env.BUN_ENV === "test" || Bun.env.NODE_ENV === "test";
101
101
  }
102
102
 
103
+ /**
104
+ * True when this code is running inside a `bun build --compile` standalone
105
+ * binary. Detects via the embedded virtual-filesystem path markers
106
+ * (`$bunfs`, `~BUN`, or its URL-encoded form `%7EBUN`) in `import.meta.url`,
107
+ * which Bun rewrites for every module bundled into the executable. The
108
+ * `PI_COMPILED` env var (set by the build script's `--define`) is checked
109
+ * first for cheap fast-path detection.
110
+ */
111
+ export function isCompiledBinary(): boolean {
112
+ if (Bun.env.PI_COMPILED) return true;
113
+ const url = import.meta.url;
114
+ return url.includes("$bunfs") || url.includes("~BUN") || url.includes("%7EBUN");
115
+ }
116
+
103
117
  const TRUTHY: Dict<boolean> = { "1": true, Y: true, TRUE: true, YES: true, ON: true };
104
118
  export function $flag(name: string, def: boolean = false): boolean {
105
119
  const value = $env[name];