pi-teams 0.9.10 → 0.9.11
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/extensions/index.ts +25 -9
- package/package.json +1 -1
package/extensions/index.ts
CHANGED
|
@@ -18,23 +18,39 @@ import { spawnSync } from "node:child_process";
|
|
|
18
18
|
/**
|
|
19
19
|
* Build the command used to relaunch pi for teammate processes.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Handles multiple installation scenarios:
|
|
22
|
+
*
|
|
23
|
+
* 1. Regular Node installs: argv[1] is the real pi launcher script on disk
|
|
24
|
+
* - execPath = /path/to/node (the interpreter)
|
|
25
|
+
* - argv[1] = /path/to/pi (the script)
|
|
26
|
+
* - We need to run the pi script directly (it has a shebang)
|
|
27
|
+
*
|
|
28
|
+
* 2. Bun-compiled binaries: argv[1] points to a virtual $bunfs path that
|
|
29
|
+
* doesn't exist on disk. execPath is the actual executable.
|
|
30
|
+
* - execPath = /path/to/pi-binary (the compiled executable)
|
|
31
|
+
* - argv[1] = /$bunfs/root/pi (virtual path, doesn't exist)
|
|
32
|
+
*
|
|
33
|
+
* 3. Fallback: If neither works, just use "pi" and hope it's on PATH.
|
|
25
34
|
*/
|
|
26
35
|
function getPiLaunchCommand(): string {
|
|
27
|
-
|
|
36
|
+
const argv1 = process.argv[1];
|
|
37
|
+
|
|
38
|
+
// First, check if argv[1] is a real "pi" file on disk (regular Node install)
|
|
39
|
+
if (argv1 && path.basename(argv1) === "pi" && fs.existsSync(argv1)) {
|
|
40
|
+
return JSON.stringify(argv1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// For Bun-compiled binaries, execPath is the actual executable
|
|
28
44
|
if (process.execPath) {
|
|
29
45
|
return JSON.stringify(process.execPath);
|
|
30
46
|
}
|
|
31
47
|
|
|
32
|
-
// Fallback: try argv[1]
|
|
33
|
-
if (
|
|
34
|
-
return `node ${JSON.stringify(
|
|
48
|
+
// Fallback: try node with argv[1]
|
|
49
|
+
if (argv1) {
|
|
50
|
+
return `node ${JSON.stringify(argv1)}`;
|
|
35
51
|
}
|
|
36
52
|
|
|
37
|
-
// Last resort: just
|
|
53
|
+
// Last resort: just "pi"
|
|
38
54
|
return "pi";
|
|
39
55
|
}
|
|
40
56
|
|