@abacus-ai/cli 2.10.15 → 2.10.16-canary.1
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/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
+
const crypto = require("node:crypto");
|
|
4
5
|
const fs = require("node:fs");
|
|
5
6
|
const path = require("node:path");
|
|
6
7
|
const os = require("node:os");
|
|
@@ -212,6 +213,8 @@ async function main() {
|
|
|
212
213
|
|
|
213
214
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "abacusai-install-"));
|
|
214
215
|
const archivePath = path.join(tmpDir, archiveName);
|
|
216
|
+
// Unique per install: two concurrent installs of one version must not copy into one file.
|
|
217
|
+
const stagedPath = `${targetPath}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.new`;
|
|
215
218
|
|
|
216
219
|
process.stdout.write(`abacusai: downloading v${version} for ${target}...\n`);
|
|
217
220
|
|
|
@@ -220,7 +223,6 @@ async function main() {
|
|
|
220
223
|
extract(archivePath, tmpDir, ext);
|
|
221
224
|
|
|
222
225
|
const sourceBinary = path.join(tmpDir, binaryName);
|
|
223
|
-
const stagedPath = `${targetPath}.new`;
|
|
224
226
|
fs.copyFileSync(sourceBinary, stagedPath);
|
|
225
227
|
if (process.platform !== "win32") fs.chmodSync(stagedPath, 0o755);
|
|
226
228
|
fs.renameSync(stagedPath, targetPath); // atomic within the version dir
|
|
@@ -230,6 +232,9 @@ async function main() {
|
|
|
230
232
|
|
|
231
233
|
process.stdout.write(`abacusai: installed v${version} to ${targetPath}\n`);
|
|
232
234
|
} finally {
|
|
235
|
+
try {
|
|
236
|
+
fs.rmSync(stagedPath, { force: true });
|
|
237
|
+
} catch {}
|
|
233
238
|
try {
|
|
234
239
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
235
240
|
} catch {}
|