MCPcopy Create free account
hub / github.com/claude-code-internals/claude-code-runnable / extractTarGz

Function extractTarGz

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

Source from the content-addressed store, hash-verified

152}
153
154async function extractTarGz(buffer, binaryPath, extractedBinary, assetName) {
155 const dir = path.dirname(binaryPath)
156 const tmpDir = path.join(dir, '.tmp-download')
157 rmSync(tmpDir, { recursive: true, force: true })
158 mkdirSync(tmpDir, { recursive: true })
159 try {
160 const archivePath = path.join(tmpDir, assetName)
161 writeFileSync(archivePath, buffer)
162 const result = spawnSync('tar', ['xzf', archivePath, '-C', tmpDir], { stdio: 'pipe' })
163 if (result.status !== 0) throw new Error(`tar extract failed: ${result.stderr?.toString()}`)
164 const srcBinary = path.join(tmpDir, extractedBinary)
165 if (!existsSync(srcBinary)) throw new Error(`Binary not found at expected path: ${srcBinary}`)
166 renameSync(srcBinary, binaryPath)
167 } finally {
168 rmSync(tmpDir, { recursive: true, force: true })
169 }
170}
171
172async function main() {
173 const { target, ext } = getPlatformMapping()

Callers 1

mainFunction · 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