archive.ts 673 B

12345678910111213141516
  1. import { $ } from "bun"
  2. import path from "path"
  3. export namespace Archive {
  4. export async function extractZip(zipPath: string, destDir: string) {
  5. if (process.platform === "win32") {
  6. const winZipPath = path.resolve(zipPath)
  7. const winDestDir = path.resolve(destDir)
  8. // $global:ProgressPreference suppresses PowerShell's blue progress bar popup
  9. const cmd = `$global:ProgressPreference = 'SilentlyContinue'; Expand-Archive -Path '${winZipPath}' -DestinationPath '${winDestDir}' -Force`
  10. await $`powershell -NoProfile -NonInteractive -Command ${cmd}`.quiet()
  11. } else {
  12. await $`unzip -o -q ${zipPath} -d ${destDir}`.quiet()
  13. }
  14. }
  15. }