@aiyiran/myclaw 1.0.15 → 1.0.16
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/package.json +1 -1
- package/wsl2.js +12 -2
package/package.json
CHANGED
package/wsl2.js
CHANGED
|
@@ -41,10 +41,20 @@ const C = isWindows
|
|
|
41
41
|
// ============================================================================
|
|
42
42
|
|
|
43
43
|
function launchElevatedPS(script) {
|
|
44
|
-
const
|
|
44
|
+
const fs = require('fs');
|
|
45
|
+
const path = require('path');
|
|
46
|
+
|
|
47
|
+
// 把脚本写到临时文件(避免 Windows 命令行长度限制)
|
|
48
|
+
const tmpDir = process.env.LOCALAPPDATA
|
|
49
|
+
? path.join(process.env.LOCALAPPDATA, 'myclaw')
|
|
50
|
+
: path.join(os.tmpdir(), 'myclaw');
|
|
51
|
+
try { fs.mkdirSync(tmpDir, { recursive: true }); } catch {}
|
|
52
|
+
const scriptPath = path.join(tmpDir, 'wsl2_installer.ps1');
|
|
53
|
+
fs.writeFileSync(scriptPath, script, 'utf8');
|
|
54
|
+
|
|
45
55
|
try {
|
|
46
56
|
execSync(
|
|
47
|
-
`powershell -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -
|
|
57
|
+
`powershell -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File \\"${scriptPath}\\"' -Verb RunAs"`,
|
|
48
58
|
{ stdio: 'inherit' }
|
|
49
59
|
);
|
|
50
60
|
return true;
|