sakitamanler-ccl-launcher 1.0.2 → 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 +12 -5
- package/package.json +1 -1
package/bin/ccl
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
const path = require('path');
|
|
6
6
|
|
|
@@ -16,11 +16,18 @@ function getTargetCommand() {
|
|
|
16
16
|
return 'ccl-darwin-x64';
|
|
17
17
|
case 'linux-x64':
|
|
18
18
|
return 'ccl-linux-x64';
|
|
19
|
-
case 'win32-x64':
|
|
19
|
+
case 'win32-x64': {
|
|
20
20
|
// Windows 下直接使用 ccl.exe
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
}
|
|
24
31
|
default:
|
|
25
32
|
throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
26
33
|
}
|