@memfork/cli 0.1.53 → 0.1.54
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 +22 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -182,9 +182,29 @@ program.parseAsync(process.argv).catch((e) => {
|
|
|
182
182
|
process.exit(1);
|
|
183
183
|
});
|
|
184
184
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
185
|
+
/**
|
|
186
|
+
* Flush stdout/stderr, then exit with `code`.
|
|
187
|
+
*
|
|
188
|
+
* Commands like `commit` open keep-alive sockets to the relayer / Sui RPC that
|
|
189
|
+
* hold Node's event loop open long after the work is done — so the process
|
|
190
|
+
* would otherwise hang for ~minutes instead of returning. Agents (Codex) read
|
|
191
|
+
* this as a stuck command and retry, producing duplicate commits. We exit
|
|
192
|
+
* explicitly once the command resolves.
|
|
193
|
+
*
|
|
194
|
+
* We can't use a bare `process.exit()` because it truncates buffered output
|
|
195
|
+
* when stdout is a pipe (which it always is under an agent). Writing an empty
|
|
196
|
+
* chunk with a callback guarantees the prior writes have drained first.
|
|
197
|
+
*/
|
|
198
|
+
function flushAndExit(code) {
|
|
199
|
+
let pending = 2;
|
|
200
|
+
const done = () => { if (--pending === 0)
|
|
201
|
+
process.exit(code); };
|
|
202
|
+
process.stdout.write("", done);
|
|
203
|
+
process.stderr.write("", done);
|
|
204
|
+
}
|
|
185
205
|
function wrap(fn) {
|
|
186
206
|
return (...args) => {
|
|
187
|
-
fn(...args).
|
|
207
|
+
fn(...args).then(() => flushAndExit(0), (e) => {
|
|
188
208
|
if (e.name === "ConfigError") {
|
|
189
209
|
console.error(chalk.red("\n " + String(e.message)));
|
|
190
210
|
console.error(chalk.cyan(" → Run `memfork init` to configure.\n"));
|
|
@@ -192,7 +212,7 @@ function wrap(fn) {
|
|
|
192
212
|
else {
|
|
193
213
|
console.error(chalk.red("\nError: " + String(e)));
|
|
194
214
|
}
|
|
195
|
-
|
|
215
|
+
flushAndExit(1);
|
|
196
216
|
});
|
|
197
217
|
};
|
|
198
218
|
}
|