MCPcopy Create free account
hub / github.com/continuedev/continue / extractArchive

Function extractArchive

binary/utils/ripgrep.js:46–70  ·  view source on GitHub ↗

* Extracts an archive to a specified directory * * @param {string} archivePath - Path to the archive file * @param {string} targetDir - Directory to extract the archive to * @param {string} platform - Platform identifier (e.g., 'darwin', 'linux', 'win32') * @returns {Promise }

(archivePath, targetDir, platform)

Source from the content-addressed store, hash-verified

44 * @returns {Promise<void>}
45 */
46async function extractArchive(archivePath, targetDir, platform) {
47 if (platform === "win32" || archivePath.endsWith(".zip")) {
48 // Simple zip extraction for Windows - extract rg.exe
49 const zip = new AdmZip(archivePath);
50
51 const rgEntry = zip
52 .getEntries()
53 .find((entry) => entry.entryName.endsWith("rg.exe"));
54
55 if (!rgEntry) {
56 throw new Error("Could not find rg.exe in the downloaded archive");
57 }
58
59 // Extract the found rg.exe file to the target directory
60 const entryData = rgEntry.getData();
61 fs.writeFileSync(path.join(targetDir, "rg.exe"), entryData);
62 } else {
63 await tar.extract({
64 file: archivePath,
65 cwd: targetDir,
66 strip: 1, // Strip the top-level directory
67 filter: (path) => path.endsWith("/rg"),
68 });
69 }
70}
71/**
72 * Downloads and installs ripgrep for the specified target
73 *

Callers 1

downloadRipgrepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected