@xynogen/pix-models 0.2.1 → 0.2.2
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.
- package/package.json +1 -1
- package/src/patch-builtin.ts +26 -11
package/package.json
CHANGED
package/src/patch-builtin.ts
CHANGED
|
@@ -19,11 +19,31 @@
|
|
|
19
19
|
* 3. createRequire against the extension's own node_modules.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import {
|
|
23
|
-
|
|
22
|
+
import {
|
|
23
|
+
accessSync,
|
|
24
|
+
constants,
|
|
25
|
+
existsSync,
|
|
26
|
+
readdirSync,
|
|
27
|
+
readFileSync,
|
|
28
|
+
realpathSync,
|
|
29
|
+
writeFileSync,
|
|
30
|
+
} from "node:fs";
|
|
24
31
|
import { createRequire } from "node:module";
|
|
25
32
|
import { homedir } from "node:os";
|
|
26
|
-
import { join, sep } from "node:path";
|
|
33
|
+
import { delimiter, join, sep } from "node:path";
|
|
34
|
+
|
|
35
|
+
/** Locate `pi` on PATH (a pure-JS `which`), returning its real (symlink-resolved) path. */
|
|
36
|
+
function resolvePiBinary(): string | undefined {
|
|
37
|
+
for (const dir of (process.env.PATH ?? "").split(delimiter)) {
|
|
38
|
+
if (!dir) continue;
|
|
39
|
+
const candidate = join(dir, "pi");
|
|
40
|
+
try {
|
|
41
|
+
accessSync(candidate, constants.X_OK);
|
|
42
|
+
return realpathSync(candidate);
|
|
43
|
+
} catch {}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
27
47
|
|
|
28
48
|
// The assignment appears once per build. `\s*=\s*\[` avoids the `.map(...)`
|
|
29
49
|
// references and tolerates both `= [` (pretty) and `=[` (minified) spacing.
|
|
@@ -42,16 +62,11 @@ function packageRoots(): string[] {
|
|
|
42
62
|
if (r && !roots.includes(r)) roots.push(r);
|
|
43
63
|
};
|
|
44
64
|
|
|
45
|
-
// 1. Resolve via the
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
encoding: "utf8",
|
|
49
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
50
|
-
}).trim();
|
|
65
|
+
// 1. Resolve via the `pi` binary on PATH → realpath → strip at /dist/.
|
|
66
|
+
const piReal = resolvePiBinary();
|
|
67
|
+
if (piReal) {
|
|
51
68
|
const idx = piReal.indexOf(`${sep}dist${sep}`);
|
|
52
69
|
if (idx >= 0) pushRoot(piReal.slice(0, idx));
|
|
53
|
-
} catch {
|
|
54
|
-
// `pi` not on PATH or `which`/`realpath` unavailable — skip
|
|
55
70
|
}
|
|
56
71
|
|
|
57
72
|
// 2. Well-known global install locations.
|