@wendongfly/myhi 1.3.93 → 1.3.95

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/bin/myhi.js CHANGED
@@ -24,6 +24,18 @@ for (let i = 0; i < args.length; i++) {
24
24
  }
25
25
  if (!cmd) cmd = args[0];
26
26
 
27
+ // --version / -v:只打印版本号就退出,绝不启动 server(否则会起孤儿进程霸占端口)
28
+ if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
29
+ try {
30
+ const pkg = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf8'));
31
+ console.log(pkg.version);
32
+ } catch (e) {
33
+ console.error('读取版本失败:', e.message);
34
+ process.exit(1);
35
+ }
36
+ process.exit(0);
37
+ }
38
+
27
39
  const configDir = join(homedir(), '.myhi');
28
40
  const pidFile = join(configDir, 'daemon.pid');
29
41
  const logFile = join(configDir, 'daemon.log');