executor 1.4.0-beta.2 → 1.4.0-beta.4
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/bin/executor +21 -7
- package/package.json +1 -1
- package/postinstall.cjs +12 -10
package/bin/executor
CHANGED
|
@@ -15,16 +15,29 @@ function run(target) {
|
|
|
15
15
|
if (process.env.EXECUTOR_BIN_PATH) run(process.env.EXECUTOR_BIN_PATH);
|
|
16
16
|
|
|
17
17
|
const scriptDir = path.dirname(fs.realpathSync(__filename));
|
|
18
|
-
const
|
|
18
|
+
const binary = process.platform === "win32" ? "executor.exe" : "executor";
|
|
19
|
+
const runtimeBinary = path.join(scriptDir, "runtime", binary);
|
|
20
|
+
const legacyCached = path.join(scriptDir, process.platform === "win32" ? ".executor.exe" : ".executor");
|
|
21
|
+
|
|
22
|
+
const resolveInstalledBinary = () => {
|
|
23
|
+
if (fs.existsSync(runtimeBinary)) {
|
|
24
|
+
return runtimeBinary;
|
|
25
|
+
}
|
|
26
|
+
if (fs.existsSync(legacyCached)) {
|
|
27
|
+
return legacyCached;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
19
31
|
|
|
20
32
|
const installIfNeeded = () => {
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
const existing = resolveInstalledBinary();
|
|
34
|
+
if (existing) {
|
|
35
|
+
return existing;
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
const installer = path.resolve(scriptDir, "..", "postinstall.cjs");
|
|
26
39
|
if (!fs.existsSync(installer)) {
|
|
27
|
-
return
|
|
40
|
+
return null;
|
|
28
41
|
}
|
|
29
42
|
|
|
30
43
|
console.error("executor binary is missing; downloading release asset...");
|
|
@@ -42,12 +55,13 @@ const installIfNeeded = () => {
|
|
|
42
55
|
process.exit(result.status);
|
|
43
56
|
}
|
|
44
57
|
|
|
45
|
-
return
|
|
58
|
+
return resolveInstalledBinary();
|
|
46
59
|
};
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
const installedBinary = installIfNeeded();
|
|
62
|
+
if (!installedBinary) {
|
|
49
63
|
console.error("executor binary is missing. Reinstall the package or run 'npm rebuild executor'.");
|
|
50
64
|
process.exit(1);
|
|
51
65
|
}
|
|
52
66
|
|
|
53
|
-
run(
|
|
67
|
+
run(installedBinary);
|
package/package.json
CHANGED
package/postinstall.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const os = require("os");
|
|
|
6
6
|
|
|
7
7
|
const packageDir = path.dirname(fs.realpathSync(__filename));
|
|
8
8
|
const binDir = path.join(packageDir, "bin");
|
|
9
|
+
const runtimeDir = path.join(binDir, "runtime");
|
|
9
10
|
const packageJson = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf8"));
|
|
10
11
|
|
|
11
12
|
const repositoryUrl = typeof packageJson.repository === "string"
|
|
@@ -20,7 +21,8 @@ const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" };
|
|
|
20
21
|
const platform = platformMap[os.platform()] || os.platform();
|
|
21
22
|
const arch = os.arch() === "arm64" ? "arm64" : "x64";
|
|
22
23
|
const binary = platform === "windows" ? "executor.exe" : "executor";
|
|
23
|
-
const cachedBinary = path.join(
|
|
24
|
+
const cachedBinary = path.join(runtimeDir, binary);
|
|
25
|
+
const legacyCachedBinary = path.join(binDir, platform === "win32" ? ".executor.exe" : ".executor");
|
|
24
26
|
|
|
25
27
|
const isMusl = (() => {
|
|
26
28
|
if (platform !== "linux") return false;
|
|
@@ -60,20 +62,22 @@ const download = async () => {
|
|
|
60
62
|
|
|
61
63
|
const extract = () => {
|
|
62
64
|
fs.mkdirSync(binDir, { recursive: true });
|
|
65
|
+
fs.rmSync(runtimeDir, { recursive: true, force: true });
|
|
66
|
+
fs.mkdirSync(runtimeDir, { recursive: true });
|
|
63
67
|
|
|
64
68
|
if (platform === "linux") {
|
|
65
|
-
run("tar", ["-xzf", archivePath, "-C",
|
|
69
|
+
run("tar", ["-xzf", archivePath, "-C", runtimeDir]);
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
if (platform === "darwin") {
|
|
70
|
-
run("unzip", ["-o", archivePath, "-d",
|
|
74
|
+
run("unzip", ["-o", archivePath, "-d", runtimeDir]);
|
|
71
75
|
return;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
const command = [
|
|
75
79
|
"$ErrorActionPreference = 'Stop'",
|
|
76
|
-
"Expand-Archive -LiteralPath '" + archivePath.replace(/'/g, "''") + "' -DestinationPath '" +
|
|
80
|
+
"Expand-Archive -LiteralPath '" + archivePath.replace(/'/g, "''") + "' -DestinationPath '" + runtimeDir.replace(/'/g, "''") + "' -Force",
|
|
77
81
|
].join("; ");
|
|
78
82
|
run("powershell.exe", ["-NoLogo", "-NoProfile", "-Command", command]);
|
|
79
83
|
};
|
|
@@ -83,15 +87,13 @@ const extract = () => {
|
|
|
83
87
|
await download();
|
|
84
88
|
extract();
|
|
85
89
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
throw new Error("Expected extracted binary at " + extractedBinary);
|
|
90
|
+
if (!fs.existsSync(cachedBinary)) {
|
|
91
|
+
throw new Error("Expected extracted binary at " + cachedBinary);
|
|
89
92
|
}
|
|
90
93
|
|
|
91
|
-
if (fs.existsSync(
|
|
92
|
-
fs.unlinkSync(
|
|
94
|
+
if (fs.existsSync(legacyCachedBinary)) {
|
|
95
|
+
fs.unlinkSync(legacyCachedBinary);
|
|
93
96
|
}
|
|
94
|
-
fs.renameSync(extractedBinary, cachedBinary);
|
|
95
97
|
fs.chmodSync(cachedBinary, 0o755);
|
|
96
98
|
fs.rmSync(archivePath, { force: true });
|
|
97
99
|
console.log("executor: installed " + assetBase + " from GitHub Releases");
|