@justestif/go-jobs 0.1.9 → 0.1.10
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 +16 -14
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -10,11 +10,11 @@ const REPO = "justEstif/go-jobs";
|
|
|
10
10
|
const VERSION = require("./package.json").version;
|
|
11
11
|
|
|
12
12
|
const PLATFORM_MAP = {
|
|
13
|
-
"linux-x64": { os: "linux", arch: "amd64", ext: ".tar.gz"
|
|
14
|
-
"linux-arm64": { os: "linux", arch: "arm64", ext: ".tar.gz"
|
|
15
|
-
"darwin-x64": { os: "darwin", arch: "amd64", ext: ".tar.gz"
|
|
16
|
-
"darwin-arm64": { os: "darwin", arch: "arm64", ext: ".tar.gz"
|
|
17
|
-
"win32-x64": { os: "windows", arch: "amd64", ext: ".zip"
|
|
13
|
+
"linux-x64": { os: "linux", arch: "amd64", ext: ".tar.gz" },
|
|
14
|
+
"linux-arm64": { os: "linux", arch: "arm64", ext: ".tar.gz" },
|
|
15
|
+
"darwin-x64": { os: "darwin", arch: "amd64", ext: ".tar.gz" },
|
|
16
|
+
"darwin-arm64": { os: "darwin", arch: "arm64", ext: ".tar.gz" },
|
|
17
|
+
"win32-x64": { os: "windows", arch: "amd64", ext: ".zip" },
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const key = `${process.platform}-${process.arch}`;
|
|
@@ -26,7 +26,7 @@ if (!plat) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const exe = process.platform === "win32" ? `${BINARY}.exe` : BINARY;
|
|
29
|
-
const archiveName = `
|
|
29
|
+
const archiveName = `jobs-cli_v${VERSION}_${plat.os}_${plat.arch}${plat.ext}`;
|
|
30
30
|
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${archiveName}`;
|
|
31
31
|
const binDir = path.join(__dirname, "bin");
|
|
32
32
|
const tmpFile = path.join(os.tmpdir(), archiveName);
|
|
@@ -73,16 +73,18 @@ download(url, tmpFile, (err) => {
|
|
|
73
73
|
|
|
74
74
|
try {
|
|
75
75
|
if (plat.ext === ".zip") {
|
|
76
|
-
// Windows: extract
|
|
77
|
-
execFileSync("
|
|
76
|
+
// Windows: use PowerShell to extract (unzip is not available by default)
|
|
77
|
+
execFileSync("powershell", [
|
|
78
|
+
"-NoProfile", "-Command",
|
|
79
|
+
`Add-Type -AssemblyName System.IO.Compression.FileSystem; ` +
|
|
80
|
+
`$zip = [System.IO.Compression.ZipFile]::OpenRead('${tmpFile.replace(/'/g, "''")}'); ` +
|
|
81
|
+
`$entry = $zip.Entries | Where-Object { $_.Name -eq '${exe}' }; ` +
|
|
82
|
+
`[System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, '${outPath.replace(/'/g, "''")}', $true); ` +
|
|
83
|
+
`$zip.Dispose()`
|
|
84
|
+
]);
|
|
78
85
|
} else {
|
|
79
|
-
// Unix: extract
|
|
86
|
+
// Unix: extract CLI binary
|
|
80
87
|
execFileSync("tar", ["-xzf", tmpFile, "-C", binDir]);
|
|
81
|
-
// Remove jobs-server if it exists
|
|
82
|
-
const serverPath = path.join(binDir, "jobs-server");
|
|
83
|
-
if (fs.existsSync(serverPath)) {
|
|
84
|
-
fs.unlinkSync(serverPath);
|
|
85
|
-
}
|
|
86
88
|
}
|
|
87
89
|
fs.chmodSync(outPath, 0o755);
|
|
88
90
|
fs.unlinkSync(tmpFile);
|