sakitamanler-ccl-launcher 1.0.1 → 1.0.3
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/ccl +17 -11
- package/package.json +1 -1
package/bin/ccl
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { spawn } = require('child_process');
|
|
3
|
+
const { spawn, execSync } = require('child_process');
|
|
4
4
|
const process = require('process');
|
|
5
|
+
const path = require('path');
|
|
5
6
|
|
|
6
7
|
// 根据平台和架构确定要执行的命令
|
|
7
8
|
function getTargetCommand() {
|
|
@@ -15,8 +16,18 @@ function getTargetCommand() {
|
|
|
15
16
|
return 'ccl-darwin-x64';
|
|
16
17
|
case 'linux-x64':
|
|
17
18
|
return 'ccl-linux-x64';
|
|
18
|
-
case 'win32-x64':
|
|
19
|
-
|
|
19
|
+
case 'win32-x64': {
|
|
20
|
+
// Windows 下直接使用 ccl.exe
|
|
21
|
+
// 获取 npm 全局 node_modules 路径
|
|
22
|
+
try {
|
|
23
|
+
const npmRoot = execSync('npm root -g', { encoding: 'utf-8' }).trim();
|
|
24
|
+
const pkgPath = path.join(npmRoot, 'sakitamanler-ccl-win32');
|
|
25
|
+
const exePath = path.join(pkgPath, 'ccl.exe');
|
|
26
|
+
return exePath;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new Error('Failed to locate npm global directory. Please ensure npm is properly installed.');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
20
31
|
default:
|
|
21
32
|
throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
22
33
|
}
|
|
@@ -53,15 +64,10 @@ function executeTargetCommand() {
|
|
|
53
64
|
let child;
|
|
54
65
|
// Windows 平台特殊处理
|
|
55
66
|
if (process.platform === 'win32') {
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
command,
|
|
59
|
-
...args.map(a => `"${a.replace(/"/g, '\\"')}"`)
|
|
60
|
-
].join(' ');
|
|
61
|
-
|
|
62
|
-
child = spawn(fullCommand, {
|
|
67
|
+
// Windows 下直接执行 ccl.exe
|
|
68
|
+
child = spawn(command, args, {
|
|
63
69
|
stdio: 'inherit',
|
|
64
|
-
shell:
|
|
70
|
+
shell: false
|
|
65
71
|
});
|
|
66
72
|
} else {
|
|
67
73
|
child = spawn(command, args, {
|