@zoria-lind/dsh-ecolink-adapter 0.1.1 → 0.1.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/modules/serviceGuard.js +10 -1
package/package.json
CHANGED
|
@@ -13,11 +13,20 @@ import { spawn } from 'node:child_process'
|
|
|
13
13
|
import { existsSync } from 'node:fs'
|
|
14
14
|
import { dirname, join } from 'node:path'
|
|
15
15
|
import { fileURLToPath } from 'node:url'
|
|
16
|
+
import { createRequire } from 'node:module'
|
|
16
17
|
|
|
17
18
|
// 同仓 service 目录(与 memoryWrite 的 SERVICE_CONFIG 同源;独立发布包无此目录 → 跳过拉起)。
|
|
18
|
-
//
|
|
19
|
+
// 三种布局都找:①npm 安装的 @zoria-lind/dsh-ecolink-service 包(尽力而为解析,不写死依赖)
|
|
20
|
+
// ②开发挂载(adapter 上一级的 service/)③独立发布包(adapter 内 service/,通常不存在)
|
|
19
21
|
const HERE = dirname(fileURLToPath(import.meta.url))
|
|
22
|
+
const NPM_SERVICE_PATH = (() => {
|
|
23
|
+
try {
|
|
24
|
+
const req = createRequire(import.meta.url)
|
|
25
|
+
return join(dirname(req.resolve('@zoria-lind/dsh-ecolink-service/package.json')), 'server.mjs')
|
|
26
|
+
} catch { return null }
|
|
27
|
+
})()
|
|
20
28
|
export const SERVICE_SERVER_CANDIDATES = [
|
|
29
|
+
...(NPM_SERVICE_PATH ? [NPM_SERVICE_PATH] : []),
|
|
21
30
|
join(HERE, '../../../service/server.mjs'),
|
|
22
31
|
join(HERE, '../../service/server.mjs'),
|
|
23
32
|
]
|