speakdrill 0.2.13 → 0.2.15
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/scripts/install.js +14 -6
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -71,6 +71,19 @@ function rmrf(p) {
|
|
|
71
71
|
if (fs.existsSync(p)) fs.rmSync(p, { recursive: true, force: true });
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// 使用 .NET ZipFile 直接解壓,避免 PowerShell Expand-Archive 的模組衝突問題
|
|
75
|
+
function extractZip(archive, dest) {
|
|
76
|
+
const psCmd = `
|
|
77
|
+
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
|
78
|
+
[System.IO.Compression.ZipFile]::ExtractToDirectory('${archive}', '${dest}')
|
|
79
|
+
`;
|
|
80
|
+
execFileSync(
|
|
81
|
+
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
|
|
82
|
+
['-NoProfile', '-Command', psCmd],
|
|
83
|
+
{ stdio: 'inherit' }
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
74
87
|
(async () => {
|
|
75
88
|
// 每次安裝都重新下載並解壓,避免沿用舊 exe 造成版本錯位
|
|
76
89
|
rmrf(outDir);
|
|
@@ -80,12 +93,7 @@ function rmrf(p) {
|
|
|
80
93
|
console.log(`[speakdrill] 下載 ${url}`);
|
|
81
94
|
try {
|
|
82
95
|
await download(url, archive);
|
|
83
|
-
|
|
84
|
-
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
|
|
85
|
-
['-NoProfile', '-Command',
|
|
86
|
-
`Expand-Archive -LiteralPath '${archive}' -DestinationPath '${outDir}' -Force`],
|
|
87
|
-
{ stdio: 'inherit' }
|
|
88
|
-
);
|
|
96
|
+
extractZip(archive, outDir);
|
|
89
97
|
fs.unlinkSync(archive);
|
|
90
98
|
ensure(outDir);
|
|
91
99
|
console.log(`[speakdrill] 安裝完成:${outDir}`);
|