| 243 | // Extract via the system tar — present on macOS, Linux, and Windows 10+ |
| 244 | // (bsdtar reads .zip too). No third-party dependency in the shim. |
| 245 | function extract(archive, destDir) { |
| 246 | var args = isWindows |
| 247 | ? ['-xf', archive, '-C', destDir, '--strip-components=1'] |
| 248 | : ['-xzf', archive, '-C', destDir, '--strip-components=1']; |
| 249 | var res = childProcess.spawnSync('tar', args, { stdio: 'ignore', windowsHide: true }); |
| 250 | if (res.error) throw new Error('tar unavailable: ' + res.error.message); |
| 251 | if (res.status !== 0) throw new Error('tar exited ' + res.status); |
| 252 | } |
| 253 | |
| 254 | function rmrf(p) { |
| 255 | try { fs.rmSync(p, { recursive: true, force: true }); } catch (e) { /* best effort */ } |