| 141 | // ── Extraction ─────────────────────────────────────────────────────────────── |
| 142 | |
| 143 | function extract(archivePath, targetDir, ext) { |
| 144 | // Both tar.gz and zip extract via system `tar`: |
| 145 | // GNU/BSD tar (macOS/Linux) handles .tar.gz natively. |
| 146 | // bsdtar (Windows 10+) handles both .tar.gz and .zip. |
| 147 | // --strip-components=1 drops the "node-vX.Y.Z-<platform>-<arch>/" top dir. |
| 148 | void ext; // archive content is identified by tar's own magic bytes |
| 149 | execFileSync( |
| 150 | "tar", |
| 151 | ["-xf", archivePath, "-C", targetDir, "--strip-components=1"], |
| 152 | { stdio: "inherit" }, |
| 153 | ); |
| 154 | } |
| 155 | |
| 156 | function ensureExecutable(p) { |
| 157 | if (process.platform === "win32") return; |