@hoplogic/hopjit 0.1.0 → 0.1.1
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/cli.js +14 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @module: hop-cli ^anc-struct-hop-cli
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import { readFileSync, readdirSync, statSync, existsSync, mkdirSync, copyFileSync, cpSync } from 'node:fs';
|
|
4
|
+
import { readFileSync, readdirSync, statSync, existsSync, mkdirSync, copyFileSync, cpSync, realpathSync } from 'node:fs';
|
|
5
5
|
import { resolve, join, isAbsolute, dirname } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { ExecutionEngine } from './engine.js';
|
|
@@ -615,7 +615,19 @@ program.command('install-skill')
|
|
|
615
615
|
}
|
|
616
616
|
});
|
|
617
617
|
export { program };
|
|
618
|
-
|
|
618
|
+
// isMain 判断须解析软链:全局装时 bin 是软链(/usr/local/bin/hopjit → .../dist/cli.js),
|
|
619
|
+
// process.argv[1] 是软链路径、import.meta.url 是真实路径,直接比对不等 → parseAsync 不跑 →
|
|
620
|
+
// 全局 hopjit 所有命令空跑 exit 0(致命)。realpathSync 解析两边软链后比对。// @a: anc-struct-hop-cli
|
|
621
|
+
function resolveRealPath(p) {
|
|
622
|
+
try {
|
|
623
|
+
return realpathSync(p);
|
|
624
|
+
}
|
|
625
|
+
catch {
|
|
626
|
+
return resolve(p);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
const isMain = process.argv[1] !== undefined
|
|
630
|
+
&& resolveRealPath(process.argv[1]) === resolveRealPath(fileURLToPath(import.meta.url));
|
|
619
631
|
if (isMain) {
|
|
620
632
|
program.parseAsync(process.argv).catch(err => {
|
|
621
633
|
errorExit(err instanceof Error ? err.message : String(err));
|
package/package.json
CHANGED