1import spawnAsync from '@expo/spawn-async'; 2import tar from 'tar'; 3 4import * as Log from '../log'; 5 6/** Extract a tar using built-in tools if available and falling back on Node.js. */ 7export async function extractAsync(input: string, output: string): Promise<void> { 8 try { 9 if (process.platform !== 'win32') { 10 await spawnAsync('tar', ['-xf', input, '-C', output], { 11 stdio: 'inherit', 12 }); 13 return; 14 } 15 } catch (error: any) { 16 Log.warn( 17 `Failed to extract tar using native tools, falling back on JS tar module. ${error.message}` 18 ); 19 } 20 // tar node module has previously had problems with big files, and seems to 21 // be slower, so only use it as a backup. 22 await tar.extract({ file: input, cwd: output }); 23} 24