@blockrun/franklin 3.15.32 → 3.15.33
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/dist/tasks/spawn.d.ts +7 -2
- package/dist/tasks/spawn.js +30 -6
- package/package.json +1 -1
package/dist/tasks/spawn.d.ts
CHANGED
|
@@ -16,8 +16,13 @@
|
|
|
16
16
|
*
|
|
17
17
|
* CLI path resolution (in priority order):
|
|
18
18
|
* 1. process.env.FRANKLIN_CLI_PATH — escape hatch for tests / dev.
|
|
19
|
-
* 2.
|
|
20
|
-
*
|
|
19
|
+
* 2. STARTUP_CLI_PATH (captured at module load) — absolute path of
|
|
20
|
+
* the script Node is currently executing. Captured early so it
|
|
21
|
+
* survives any later chdir; resolved to absolute so it survives
|
|
22
|
+
* the spawn's `cwd:` override (the bug it fixes — verified
|
|
23
|
+
* 2026-05-04 from a real session: dev-mode `node dist/index.js`
|
|
24
|
+
* run, then Detach with workingDir=other-repo, child fails with
|
|
25
|
+
* MODULE_NOT_FOUND on `<other-repo>/dist/index.js`).
|
|
21
26
|
*/
|
|
22
27
|
export interface StartDetachedTaskInput {
|
|
23
28
|
label: string;
|
package/dist/tasks/spawn.js
CHANGED
|
@@ -16,22 +16,46 @@
|
|
|
16
16
|
*
|
|
17
17
|
* CLI path resolution (in priority order):
|
|
18
18
|
* 1. process.env.FRANKLIN_CLI_PATH — escape hatch for tests / dev.
|
|
19
|
-
* 2.
|
|
20
|
-
*
|
|
19
|
+
* 2. STARTUP_CLI_PATH (captured at module load) — absolute path of
|
|
20
|
+
* the script Node is currently executing. Captured early so it
|
|
21
|
+
* survives any later chdir; resolved to absolute so it survives
|
|
22
|
+
* the spawn's `cwd:` override (the bug it fixes — verified
|
|
23
|
+
* 2026-05-04 from a real session: dev-mode `node dist/index.js`
|
|
24
|
+
* run, then Detach with workingDir=other-repo, child fails with
|
|
25
|
+
* MODULE_NOT_FOUND on `<other-repo>/dist/index.js`).
|
|
21
26
|
*/
|
|
22
27
|
import { spawn } from 'node:child_process';
|
|
23
28
|
import fs from 'node:fs';
|
|
29
|
+
import path from 'node:path';
|
|
24
30
|
import { randomUUID } from 'node:crypto';
|
|
25
31
|
import { writeTaskMeta } from './store.js';
|
|
26
32
|
import { taskLogPath, ensureTaskDir } from './paths.js';
|
|
33
|
+
// Captured at module load so it survives later chdir / argv mutation.
|
|
34
|
+
// `process.argv[1]` may be relative (`dist/index.js` in dev mode); we
|
|
35
|
+
// resolve against process.cwd() at startup which is when the user's
|
|
36
|
+
// shell exec'd the bundle. Doing this at call time would be wrong if
|
|
37
|
+
// any code chdir'd between startup and the Detach call.
|
|
38
|
+
const STARTUP_CLI_PATH = (() => {
|
|
39
|
+
const argv1 = process.argv[1];
|
|
40
|
+
if (!argv1)
|
|
41
|
+
return undefined;
|
|
42
|
+
try {
|
|
43
|
+
return path.resolve(argv1);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return argv1;
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
27
49
|
function resolveCliPath() {
|
|
28
50
|
const fromEnv = process.env.FRANKLIN_CLI_PATH;
|
|
29
51
|
if (fromEnv && fromEnv.length > 0)
|
|
30
52
|
return fromEnv;
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
|
|
53
|
+
// STARTUP_CLI_PATH is the absolute path resolved at module load —
|
|
54
|
+
// safe to use after `cwd: input.workingDir` redirects the child.
|
|
55
|
+
// npm global installs already give an absolute path; this only
|
|
56
|
+
// matters in dev mode where `node dist/index.js` puts a relative
|
|
57
|
+
// path into argv[1].
|
|
58
|
+
return STARTUP_CLI_PATH || process.argv[1];
|
|
35
59
|
}
|
|
36
60
|
function generateRunId() {
|
|
37
61
|
return `t_${Date.now().toString(36)}_${randomUUID().slice(0, 8)}`;
|
package/package.json
CHANGED