@patchgg/cli 0.1.2 → 0.1.3
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/dist/cli.js +15 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -176,7 +176,7 @@ var VERSION;
|
|
|
176
176
|
var init_version = __esm({
|
|
177
177
|
"src/version.ts"() {
|
|
178
178
|
"use strict";
|
|
179
|
-
VERSION = true ? "0.1.
|
|
179
|
+
VERSION = true ? "0.1.3" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
|
|
@@ -48908,6 +48908,7 @@ import { createHash as createHash4 } from "node:crypto";
|
|
|
48908
48908
|
import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
48909
48909
|
import { chmod as chmod3, rename as rename2, rm as rm3, writeFile as writeFile13 } from "node:fs/promises";
|
|
48910
48910
|
import { basename as basename8, dirname as dirname7, join as join19 } from "node:path";
|
|
48911
|
+
import { setTimeout as sleep10 } from "node:timers/promises";
|
|
48911
48912
|
import { gunzipSync } from "node:zlib";
|
|
48912
48913
|
init_errors();
|
|
48913
48914
|
init_version();
|
|
@@ -49017,7 +49018,7 @@ async function update(ctx) {
|
|
|
49017
49018
|
await chmod3(fresh, 493);
|
|
49018
49019
|
const said2 = spawnSync2(fresh, ["--version"], { encoding: "utf8", timeout: 6e4 });
|
|
49019
49020
|
if (said2.status !== 0 || said2.stdout.trim() !== latest2) {
|
|
49020
|
-
await rm3(fresh, { force: true });
|
|
49021
|
+
await whenFree(() => rm3(fresh, { force: true })).catch(() => void 0);
|
|
49021
49022
|
throw new CliError(
|
|
49022
49023
|
EXIT.error,
|
|
49023
49024
|
"update_failed",
|
|
@@ -49037,12 +49038,23 @@ async function replace(target, fresh) {
|
|
|
49037
49038
|
const old = `${target}.${process.pid}.old`;
|
|
49038
49039
|
await rename2(target, old);
|
|
49039
49040
|
try {
|
|
49040
|
-
await rename2(fresh, target);
|
|
49041
|
+
await whenFree(() => rename2(fresh, target));
|
|
49041
49042
|
} catch (error62) {
|
|
49042
49043
|
await rename2(old, target);
|
|
49043
49044
|
throw error62;
|
|
49044
49045
|
}
|
|
49045
49046
|
}
|
|
49047
|
+
async function whenFree(step, wait2 = 200) {
|
|
49048
|
+
for (let attempt = 1; ; attempt++) {
|
|
49049
|
+
try {
|
|
49050
|
+
return await step();
|
|
49051
|
+
} catch (error62) {
|
|
49052
|
+
const code = error62.code ?? "";
|
|
49053
|
+
if (attempt >= 10 || !["EBUSY", "EPERM", "EACCES"].includes(code)) throw error62;
|
|
49054
|
+
await sleep10(attempt * wait2);
|
|
49055
|
+
}
|
|
49056
|
+
}
|
|
49057
|
+
}
|
|
49046
49058
|
function removeOldExecutables(target = process.execPath) {
|
|
49047
49059
|
if (!isExecutable || process.platform !== "win32") return;
|
|
49048
49060
|
const folder = dirname7(target);
|