mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
fix: Use PowerShell Expand-Archive for zip extraction on Windows (#190)
The npm postinstall script used `unzip` to extract .zip archives, but `unzip` is not available by default on Windows, causing installation to fail with a `spawn UNKNOWN` error. Use PowerShell's `Expand-Archive` on Windows instead, which is available since PowerShell 5.0 (Windows 10+). Fixes #187 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
8e563ee5a1
commit
be4b751091
+10
-1
@@ -109,7 +109,16 @@ function extractArchive(archivePath, extractDir) {
|
|||||||
const isZip = archivePath.endsWith(".zip");
|
const isZip = archivePath.endsWith(".zip");
|
||||||
|
|
||||||
if (isZip) {
|
if (isZip) {
|
||||||
execSync(`unzip -o "${archivePath}" -d "${extractDir}"`, { stdio: "pipe" });
|
if (process.platform === "win32") {
|
||||||
|
execSync(
|
||||||
|
`powershell -NoProfile -Command "Expand-Archive -Force -Path '${archivePath}' -DestinationPath '${extractDir}'"`,
|
||||||
|
{ stdio: "pipe" },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
execSync(`unzip -o "${archivePath}" -d "${extractDir}"`, {
|
||||||
|
stdio: "pipe",
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
execSync(`tar -xzf "${archivePath}" -C "${extractDir}"`, { stdio: "pipe" });
|
execSync(`tar -xzf "${archivePath}" -C "${extractDir}"`, { stdio: "pipe" });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user