@persistmemory/cli 0.2.2 → 0.2.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/index.js CHANGED
@@ -1525,7 +1525,7 @@ function shortDate(iso) {
1525
1525
  }
1526
1526
 
1527
1527
  // src/help.ts
1528
- var VERSION = true ? "0.2.2" : versionFromManifest();
1528
+ var VERSION = true ? "0.2.3" : versionFromManifest();
1529
1529
  var PACKAGE = "@persistmemory/cli";
1530
1530
  var HELP = `
1531
1531
  pm \u2014 PersistMemory from your terminal
@@ -2095,14 +2095,18 @@ async function currentCredential(resolved, deps) {
2095
2095
 
2096
2096
  // src/context.ts
2097
2097
  import { createInterface } from "node:readline";
2098
- async function askOnTty(prompt) {
2098
+ async function askOnTty(prompt, input = process.stdin, output = process.stdout) {
2099
2099
  return new Promise((resolve8) => {
2100
- const readline = createInterface({ input: process.stdin, output: process.stdout });
2100
+ const readline = createInterface({ input, output });
2101
+ let answered = false;
2101
2102
  readline.question(prompt, (answer3) => {
2102
- readline.close();
2103
+ answered = true;
2103
2104
  resolve8(answer3.trim());
2105
+ readline.close();
2106
+ });
2107
+ readline.once("close", () => {
2108
+ if (!answered) resolve8("");
2104
2109
  });
2105
- readline.once("close", () => resolve8(""));
2106
2110
  });
2107
2111
  }
2108
2112
  var ETX = "";
@@ -2113,11 +2117,15 @@ async function readSecretFromTty(prompt) {
2113
2117
  if (!input.isTTY) {
2114
2118
  return new Promise((resolve8) => {
2115
2119
  const readline = createInterface({ input });
2120
+ let answered = false;
2116
2121
  readline.once("line", (line) => {
2117
- readline.close();
2122
+ answered = true;
2118
2123
  resolve8(line.trim());
2124
+ readline.close();
2125
+ });
2126
+ readline.once("close", () => {
2127
+ if (!answered) resolve8("");
2119
2128
  });
2120
- readline.once("close", () => resolve8(""));
2121
2129
  });
2122
2130
  }
2123
2131
  process.stdout.write(prompt);