@hanzo/cli 8.5.924 → 8.5.927
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.js +28 -6
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -63,6 +63,25 @@ async function get(url) {
|
|
|
63
63
|
return res;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
function resolveTarExecutable(platform = process.platform, systemRoot = process.env.SystemRoot) {
|
|
67
|
+
if (platform !== "win32") return "tar";
|
|
68
|
+
if (!systemRoot) {
|
|
69
|
+
throw new Error("SystemRoot is not set; cannot locate Windows system tar");
|
|
70
|
+
}
|
|
71
|
+
const systemTar = join(systemRoot, "System32", "tar.exe");
|
|
72
|
+
if (!existsSync(systemTar)) {
|
|
73
|
+
throw new Error(`Windows system tar not found at ${systemTar}`);
|
|
74
|
+
}
|
|
75
|
+
return systemTar;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function extractArchive(archive, dest, options) {
|
|
79
|
+
mkdirSync(dest, { recursive: true });
|
|
80
|
+
execFileSync(resolveTarExecutable(options?.platform, options?.systemRoot), [
|
|
81
|
+
"-xzf", archive, "-C", dest,
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
|
|
66
85
|
function linkAlias(dest, binName, aliasName, ext) {
|
|
67
86
|
if (!aliasName) return;
|
|
68
87
|
const src = join(dest, `${binName}${ext}`);
|
|
@@ -97,8 +116,7 @@ async function downloadAndExtract({ assetUrl, sha256Url, assetName, dest }) {
|
|
|
97
116
|
throw new Error(`checksum mismatch for ${assetName}\n expected ${want}\n got ${got}`);
|
|
98
117
|
}
|
|
99
118
|
|
|
100
|
-
|
|
101
|
-
execFileSync("tar", ["-xzf", tmp, "-C", dest]);
|
|
119
|
+
extractArchive(tmp, dest);
|
|
102
120
|
await rm(tmp, { force: true });
|
|
103
121
|
}
|
|
104
122
|
|
|
@@ -290,7 +308,11 @@ async function main() {
|
|
|
290
308
|
}
|
|
291
309
|
}
|
|
292
310
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
311
|
+
if (require.main === module) {
|
|
312
|
+
main().catch((err) => {
|
|
313
|
+
console.error(`@hanzo/cli: ${err.message}`);
|
|
314
|
+
process.exit(1);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
module.exports = { extractArchive, resolveTarExecutable };
|