| 219 | // Extract via the system tar — present on macOS, Linux, and Windows 10+ |
| 220 | // (bsdtar reads .zip too). No third-party dependency in the shim. |
| 221 | function extract(archive, destDir) { |
| 222 | var args = isWindows |
| 223 | ? ['-xf', archive, '-C', destDir, '--strip-components=1'] |
| 224 | : ['-xzf', archive, '-C', destDir, '--strip-components=1']; |
| 225 | var res = childProcess.spawnSync('tar', args, { stdio: 'ignore', windowsHide: true }); |
| 226 | if (res.error) throw new Error('tar unavailable: ' + res.error.message); |
| 227 | if (res.status !== 0) throw new Error('tar exited ' + res.status); |
| 228 | } |
| 229 | |
| 230 | function rmrf(p) { |
| 231 | try { fs.rmSync(p, { recursive: true, force: true }); } catch (e) { /* best effort */ } |