@seamnet/client 0.16.1 → 0.16.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/lib/guardian.js +7 -3
- package/package.json +1 -1
package/lib/guardian.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { existsSync, readFileSync, writeFileSync, unlinkSync, mkdirSync, openSync, readlinkSync } from 'node:fs';
|
|
15
|
-
import { join, isAbsolute } from 'node:path';
|
|
15
|
+
import { join, isAbsolute, dirname } from 'node:path';
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
16
17
|
import { execSync, spawn } from 'node:child_process';
|
|
17
18
|
import { SEAM_DIR, CREDENTIALS_PATH, SOCKET_PATH, LOGS_DIR, PID_PATH } from './paths.js';
|
|
18
19
|
import { writeEntry as registryWrite, removeEntry as registryRemove } from './registry.js';
|
|
@@ -101,11 +102,14 @@ export async function guardianStart() {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
const cwd = process.cwd();
|
|
104
|
-
|
|
105
|
+
// guardian-run 进程从 guardian.js 自己所属的包启动(lib/guardian.js → ../bin/cli.js)。
|
|
106
|
+
// 不再相对 cwd 找 node_modules——那样既不支持全局安装(host-tool 模式),
|
|
107
|
+
// cwd 不是项目根时还会崩。模块自解析保证 spawn 出的 guardian 跟当前代码同版本。
|
|
108
|
+
const selfCli = join(dirname(fileURLToPath(import.meta.url)), '..', 'bin', 'cli.js');
|
|
105
109
|
const logPath = join(LOGS_DIR, 'guardian.log');
|
|
106
110
|
const logFd = openSync(logPath, 'a');
|
|
107
111
|
|
|
108
|
-
const child = spawn(process.execPath, [
|
|
112
|
+
const child = spawn(process.execPath, [selfCli, 'guardian', 'run'], {
|
|
109
113
|
cwd,
|
|
110
114
|
detached: true,
|
|
111
115
|
stdio: ['ignore', logFd, logFd],
|