buddy-reroll 0.3.1 → 0.3.2
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/index.js +5 -2
- package/package.json +1 -1
- package/ui.jsx +2 -0
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { readFileSync, writeFileSync, existsSync, copyFileSync, renameSync, unlinkSync } from "fs";
|
|
3
|
+
import { readFileSync, writeFileSync, existsSync, copyFileSync, renameSync, unlinkSync, statSync, chmodSync } from "fs";
|
|
4
4
|
import { platform } from "os";
|
|
5
5
|
import { execFileSync, spawnSync } from "child_process";
|
|
6
6
|
import { parseArgs } from "util";
|
|
@@ -75,6 +75,7 @@ function patchBinary(binaryPath, oldSalt, newSalt) {
|
|
|
75
75
|
throw new Error(`Salt length mismatch: "${oldSalt}" (${oldSalt.length}) vs "${newSalt}" (${newSalt.length})`);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
const originalMode = statSync(binaryPath).mode;
|
|
78
79
|
const data = readFileSync(binaryPath);
|
|
79
80
|
const oldBuf = Buffer.from(oldSalt);
|
|
80
81
|
const newBuf = Buffer.from(newSalt);
|
|
@@ -96,7 +97,7 @@ function patchBinary(binaryPath, oldSalt, newSalt) {
|
|
|
96
97
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
97
98
|
try {
|
|
98
99
|
const tmpPath = binaryPath + ".tmp";
|
|
99
|
-
writeFileSync(tmpPath, data);
|
|
100
|
+
writeFileSync(tmpPath, data, { mode: originalMode });
|
|
100
101
|
try {
|
|
101
102
|
renameSync(tmpPath, binaryPath);
|
|
102
103
|
} catch {
|
|
@@ -106,6 +107,8 @@ function patchBinary(binaryPath, oldSalt, newSalt) {
|
|
|
106
107
|
renameSync(tmpPath, binaryPath);
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
chmodSync(binaryPath, originalMode);
|
|
111
|
+
|
|
109
112
|
const verify = readFileSync(binaryPath);
|
|
110
113
|
const found = verify.indexOf(Buffer.from(newSalt));
|
|
111
114
|
if (found === -1) throw new Error("Patch verification failed — new salt not found after write");
|
package/package.json
CHANGED
package/ui.jsx
CHANGED
|
@@ -130,6 +130,7 @@ function ShowCurrentStep({ isActive }) {
|
|
|
130
130
|
|
|
131
131
|
useInput(() => {
|
|
132
132
|
exit();
|
|
133
|
+
setTimeout(() => process.exit(0), 100);
|
|
133
134
|
}, { isActive });
|
|
134
135
|
|
|
135
136
|
return (
|
|
@@ -218,6 +219,7 @@ function DoneStep({ messages, isActive }) {
|
|
|
218
219
|
|
|
219
220
|
useInput(() => {
|
|
220
221
|
exit();
|
|
222
|
+
setTimeout(() => process.exit(0), 100);
|
|
221
223
|
}, { isActive });
|
|
222
224
|
|
|
223
225
|
return (
|