MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / extractTarGz

Function extractTarGz

scripts/postinstall.cjs:283–305  ·  view source on GitHub ↗
(buffer, binaryPath, extractedBinary, assetName)

Source from the content-addressed store, hash-verified

281}
282
283async function extractTarGz(buffer, binaryPath, extractedBinary, assetName) {
284 const binaryDir = path.dirname(binaryPath)
285 const tmpDir = path.join(binaryDir, '.tmp-download')
286 rmSync(tmpDir, { recursive: true, force: true })
287 mkdirSync(tmpDir, { recursive: true })
288 try {
289 const archivePath = path.join(tmpDir, assetName)
290 writeFileSync(archivePath, buffer)
291 const result = spawnSync('tar', ['xzf', archivePath, '-C', tmpDir], {
292 stdio: 'pipe',
293 })
294 if (result.status !== 0) {
295 throw new Error(`tar extract failed: ${result.stderr?.toString()}`)
296 }
297 const srcBinary = path.join(tmpDir, extractedBinary)
298 if (!existsSync(srcBinary)) {
299 throw new Error(`Binary not found at expected path: ${srcBinary}`)
300 }
301 renameSync(srcBinary, binaryPath)
302 } finally {
303 rmSync(tmpDir, { recursive: true, force: true })
304 }
305}
306
307// --- Main ---
308

Callers 1

downloadAndExtractFunction · 0.85

Calls 5

rmSyncFunction · 0.85
mkdirSyncFunction · 0.85
existsSyncFunction · 0.85
renameSyncFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected