@agfpd/iapeer 0.2.66 → 0.2.67
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
CHANGED
package/src/supervisor/index.ts
CHANGED
|
@@ -76,13 +76,15 @@ export interface StartDaemonResult {
|
|
|
76
76
|
* re-invoke the installed binary through its `supervisor` verb instead. The caller appends
|
|
77
77
|
* `daemon <session> <runtime> --run-dir <dir>`, so runSupervisorCli is reached either way.
|
|
78
78
|
*/
|
|
79
|
-
export function resolveDaemonSelfArgv(execPath: string, selfPath: string
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
export function resolveDaemonSelfArgv(execPath: string, selfPath: string): string[] {
|
|
80
|
+
// A `bun build --compile` standalone embeds this module at a `/$bunfs/root/…` virtual path
|
|
81
|
+
// (verified: import.meta.url → file:///$bunfs/root/…). `existsSync` is NO discriminator — Bun
|
|
82
|
+
// intercepts bunfs reads so it is true for BOTH src and compiled. The `$bunfs` marker in the self
|
|
83
|
+
// path IS the discriminator: compiled → re-invoke the installed binary through its `supervisor` verb
|
|
84
|
+
// (the caller appends `daemon …`); source → a real on-disk file, run it directly via the runtime.
|
|
85
|
+
return selfPath.includes('$bunfs') ? [execPath, 'supervisor'] : [execPath, selfPath]
|
|
85
86
|
}
|
|
87
|
+
const selfArgv = (): string[] => resolveDaemonSelfArgv(process.execPath, fileURLToPath(import.meta.url))
|
|
86
88
|
|
|
87
89
|
/** Start a detached supervisor daemon and wait until its socket is live. Idempotent. */
|
|
88
90
|
export function startSupervisorDaemon(opts: StartDaemonOptions): StartDaemonResult {
|
|
@@ -7,15 +7,16 @@ import { describe, expect, test } from 'bun:test'
|
|
|
7
7
|
import { resolveDaemonSelfArgv } from './index.ts'
|
|
8
8
|
|
|
9
9
|
describe('resolveDaemonSelfArgv', () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// Paths are the EMPIRICALLY-verified shapes: bun → real /private/... file; compiled → /$bunfs/root/...
|
|
11
|
+
test('source (real on-disk module) → re-run the module directly via the runtime (bun)', () => {
|
|
12
|
+
expect(resolveDaemonSelfArgv('/Users/x/.bun/bin/bun', '/Users/x/iapeer/src/supervisor/index.ts'))
|
|
13
|
+
.toEqual(['/Users/x/.bun/bin/bun', '/Users/x/iapeer/src/supervisor/index.ts'])
|
|
13
14
|
})
|
|
14
15
|
|
|
15
|
-
test('compiled standalone (
|
|
16
|
-
expect(resolveDaemonSelfArgv('/Users/x/.local/bin/iapeer', '/$bunfs/root/src/supervisor/index.ts'
|
|
16
|
+
test('compiled standalone (embedded /$bunfs path) → installed binary + `supervisor` verb', () => {
|
|
17
|
+
expect(resolveDaemonSelfArgv('/Users/x/.local/bin/iapeer', '/$bunfs/root/src/supervisor/index.ts'))
|
|
17
18
|
.toEqual(['/Users/x/.local/bin/iapeer', 'supervisor'])
|
|
18
19
|
// The caller appends `daemon <session> <runtime> --run-dir <dir>` → `iapeer supervisor daemon …`,
|
|
19
|
-
// which the CLI routes to runSupervisorCli('daemon', …). NOT a bare bunfs-path (→ usage).
|
|
20
|
+
// which the CLI routes to runSupervisorCli('daemon', …). NOT a bare bunfs-path (→ usage dump).
|
|
20
21
|
})
|
|
21
22
|
})
|