archive.ts 696 B

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