MCPcopy
hub / github.com/larksuite/cli / extractZipWindows

Function extractZipWindows

scripts/install.js:178–212  ·  view source on GitHub ↗
(archivePath, destDir)

Source from the content-addressed store, hash-verified

176}
177
178function extractZipWindows(archivePath, destDir) {
179 const psOpts = ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"];
180 const psStdio = ["ignore", "inherit", "inherit"];
181 const psEnv = {
182 ...process.env,
183 LARK_CLI_ARCHIVE: archivePath,
184 LARK_CLI_DEST: destDir,
185 };
186
187 try {
188 const dotnet =
189 "$ErrorActionPreference='Stop';" +
190 "Add-Type -AssemblyName System.IO.Compression.FileSystem;" +
191 "[System.IO.Compression.ZipFile]::ExtractToDirectory($env:LARK_CLI_ARCHIVE,$env:LARK_CLI_DEST)";
192 execFileSync("powershell.exe", [...psOpts, dotnet], { stdio: psStdio, env: psEnv });
193 } catch (primaryErr) {
194 try {
195 const cmdlet =
196 "$ErrorActionPreference='Stop';" +
197 "Expand-Archive -LiteralPath $env:LARK_CLI_ARCHIVE -DestinationPath $env:LARK_CLI_DEST -Force";
198 execFileSync("powershell.exe", [...psOpts, cmdlet], { stdio: psStdio, env: psEnv });
199 } catch (secondErr) {
200 try {
201 execFileSync("tar", ["-xf", archivePath, "-C", destDir], { stdio: psStdio });
202 } catch (fallbackErr) {
203 throw new Error(
204 `Failed to extract ${archivePath}. ` +
205 `.NET ZipFile attempt: ${primaryErr.message}. ` +
206 `Expand-Archive fallback: ${secondErr.message}. ` +
207 `tar fallback: ${fallbackErr.message}`
208 );
209 }
210 }
211 }
212}
213
214function install() {
215 const mirrorUrls = getMirrorUrls(process.env);

Callers 1

installFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected