dsh-memory-engine 0.5.1 → 0.5.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/scripts/render-map.mjs +20 -2
package/package.json
CHANGED
package/scripts/render-map.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { realpathSync } from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { MemoryStore } from '../lib/store.js';
|
|
5
6
|
import { generateMap, mapReport, openMap } from '../lib/map.js';
|
|
@@ -25,4 +26,21 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
25
26
|
return 1;
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
// 入口判定:必须比较「真实路径」。
|
|
31
|
+
// pnpm 把包装在 node_modules/.pnpm 下,再用符号链接指过去;
|
|
32
|
+
// import.meta.url 是解析链接后的真实路径,而 process.argv[1] 是链接路径,
|
|
33
|
+
// 直接比较会不相等 → main() 不执行 → 静默失败(退出码 0、无输出、不生成文件)。
|
|
34
|
+
function isEntryPoint() {
|
|
35
|
+
const argv1 = process.argv[1];
|
|
36
|
+
if (!argv1) return false;
|
|
37
|
+
const self = fileURLToPath(import.meta.url);
|
|
38
|
+
try {
|
|
39
|
+
return path.resolve(realpathSync(argv1)) === path.resolve(realpathSync(self));
|
|
40
|
+
} catch {
|
|
41
|
+
// 任何一方解析失败(文件已删等)就退回到字面比较
|
|
42
|
+
return path.resolve(argv1) === path.resolve(self);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isEntryPoint()) process.exitCode = await main();
|