(archivePath: string, extractDir: string, assetName: string)
| 157 | } |
| 158 | |
| 159 | function extractArchive(archivePath: string, extractDir: string, assetName: string): void { |
| 160 | if (assetName.endsWith('.tar.gz')) { |
| 161 | runExtractionCommand('tar', ['xzf', archivePath, '-C', extractDir]); |
| 162 | return; |
| 163 | } |
| 164 | if (assetName.endsWith('.zip')) { |
| 165 | if (platform() === 'win32') { |
| 166 | runExtractionCommand(getWindowsTarCommand(), ['xf', archivePath, '-C', extractDir]); |
| 167 | return; |
| 168 | } |
| 169 | runExtractionCommand('unzip', ['-q', archivePath, '-d', extractDir]); |
| 170 | return; |
| 171 | } |
| 172 | throw new Error(`Unsupported fd archive format: ${assetName}`); |
| 173 | } |
| 174 | |
| 175 | function runExtractionCommand(command: string, args: readonly string[]): void { |
| 176 | const result = spawnSync(command, [...args], { stdio: 'pipe' }); |
no test coverage detected