@yangrunchi/a_6 1.0.0 → 1.0.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/cli.js +42 -5
- package/package.json +1 -1
- package/run-client.bat +13 -0
package/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
// a_6 命令行入口
|
|
3
|
-
const { execSync } = require('child_process');
|
|
3
|
+
const { execSync, exec } = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
5
6
|
|
|
6
7
|
const action = process.argv[2];
|
|
7
8
|
|
|
@@ -24,6 +25,42 @@ if (!commands[action]) {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const cmd = commands[action];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
// 特殊处理:启动客户端需要找到项目根目录的 exe
|
|
30
|
+
if (action === '1') {
|
|
31
|
+
console.log(`🚀 执行: ${cmd.desc}`);
|
|
32
|
+
// 从当前工作目录向上查找 996M2_Client.exe
|
|
33
|
+
let cwd = process.cwd();
|
|
34
|
+
let exePath = null;
|
|
35
|
+
for (let i = 0; i < 5; i++) {
|
|
36
|
+
const testPath = path.join(cwd, '996M2_Client.exe');
|
|
37
|
+
if (fs.existsSync(testPath)) {
|
|
38
|
+
exePath = testPath;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
const parent = path.dirname(cwd);
|
|
42
|
+
if (parent === cwd) break; // 到达根目录
|
|
43
|
+
cwd = parent;
|
|
44
|
+
}
|
|
45
|
+
if (!exePath) {
|
|
46
|
+
console.error('错误: 找不到 996M2_Client.exe');
|
|
47
|
+
console.error('请在 996M2_Client 项目目录下运行 a_6 1');
|
|
48
|
+
console.error('或者 cd 到包含 996M2_Client.exe 的目录');
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
console.log(`启动 996M2 客户端...`);
|
|
52
|
+
console.log(`路径: ${exePath}`);
|
|
53
|
+
exec(`start "" "${exePath}"`, (err) => {
|
|
54
|
+
if (err) {
|
|
55
|
+
console.error('启动失败:', err.message);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
console.log('客户端已启动');
|
|
59
|
+
});
|
|
60
|
+
// 给异步回调一点时间
|
|
61
|
+
setTimeout(() => process.exit(0), 2000);
|
|
62
|
+
} else {
|
|
63
|
+
const batFile = path.join(__dirname, cmd.file);
|
|
64
|
+
console.log(`🚀 执行: ${cmd.desc}`);
|
|
65
|
+
execSync(`"${batFile}"`, { stdio: 'inherit', shell: true });
|
|
66
|
+
}
|
package/package.json
CHANGED
package/run-client.bat
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
@echo off
|
|
2
2
|
chcp 65001 >nul
|
|
3
|
+
|
|
4
|
+
:: 如果从命令行传入了 exe 路径参数,优先使用
|
|
5
|
+
if not "%~1"=="" (
|
|
6
|
+
if exist "%~1" (
|
|
7
|
+
echo 启动 996M2 客户端...
|
|
8
|
+
start "" "%~1"
|
|
9
|
+
echo 客户端已启动
|
|
10
|
+
exit /b 0
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
:: 否则尝试相对路径(本地开发模式)
|
|
3
15
|
set "client_path=%~dp0..\..\996M2_Client.exe"
|
|
4
16
|
|
|
5
17
|
if not exist "%client_path%" (
|
|
6
18
|
echo 错误: 找不到 996M2_Client.exe
|
|
7
19
|
echo 期望路径: %client_path%
|
|
20
|
+
echo 请在 996M2_Client 项目目录下运行此命令
|
|
8
21
|
pause
|
|
9
22
|
exit /b 1
|
|
10
23
|
)
|