| 230 | // Extract via the system tar — present on macOS, Linux, and Windows 10+ |
| 231 | // (bsdtar reads .zip too). No third-party dependency in the shim. |
| 232 | function extract(archive, destDir) { |
| 233 | var args = isWindows |
| 234 | ? ['-xf', archive, '-C', destDir, '--strip-components=1'] |
| 235 | : ['-xzf', archive, '-C', destDir, '--strip-components=1']; |
| 236 | var res = childProcess.spawnSync('tar', args, { stdio: 'ignore', windowsHide: true }); |
| 237 | if (res.error) throw new Error('tar unavailable: ' + res.error.message); |
| 238 | if (res.status !== 0) throw new Error('tar exited ' + res.status); |
| 239 | } |
| 240 | |
| 241 | function rmrf(p) { |
| 242 | try { fs.rmSync(p, { recursive: true, force: true }); } catch (e) { /* best effort */ } |