Skip to content

Commit

Permalink
Adds support for Powershell on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ManasJayanth committed Jun 21, 2024
1 parent 1846731 commit 3dbda34
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 37 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
"commander": "^8.3.0",
"debug": "^4.3.2",
"fs-extra": "^11.1.1",
"gunzip-maybe": "^1.4.2",
"npm-profile": "^7.0.1",
"promisepipe": "^3.0.0",
"rimraf": "^4.4.1",
"tar-fs": "^3.0.6",
"verdaccio": "^5.23.1"
}
}
26 changes: 21 additions & 5 deletions src/lib/compression.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
import * as cp from "child_process";
import * as fs from "fs";
import * as path from "path";
import { cygpath } from "./utils";
import Debug from "debug";
import promisepipe from "promisepipe";
import tarFs from "tar-fs";
import gunzipMaybe from "gunzip-maybe";

const debug = Debug("bale:compression");

async function extractTarball(filePath: string, destDir: string) {
await promisepipe(
fs.createReadStream(filePath),
gunzipMaybe(),
tarFs.extract(destDir),
);
}

export async function tar(filePath, destDir, gzip?) {
filePath = await cygpath(filePath);
destDir = await cygpath(destDir);
const cmd = `tar -x${gzip ? "z" : ""}f ${filePath} -C ${destDir}`;
debug("Running", cmd);
cp.execSync(cmd, {
stdio: "inherit",
});
if (process.platform === "win32") {
await extractTarball(filePath, destDir);
} else {
const cmd = `tar -x${gzip ? "z" : ""}f ${filePath} -C ${destDir}`;
debug("Running", cmd);
cp.execSync(cmd, {
stdio: "inherit",
});
}
}

export async function unzip(filePath, destDir) {
Expand Down
Loading

0 comments on commit 3dbda34

Please sign in to comment.