cherrypick-interactive 1.14.2 → 1.14.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tui/index.js +29 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cherrypick-interactive",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "description": "Interactively cherry-pick commits that are in dev but not in main, using subject-based comparison.",
5
5
  "main": "cli.js",
6
6
  "bin": "cli.js",
package/src/tui/index.js CHANGED
@@ -2,6 +2,22 @@ import { render } from 'ink';
2
2
  import { createElement } from 'react';
3
3
  import { App } from './App.js';
4
4
 
5
+ /**
6
+ * Restore process.stdin after ink unmount.
7
+ * Ink sets stdin.setRawMode(false) and stdin.unref() on cleanup (App.js),
8
+ * which causes subsequent inquirer prompts to immediately throw
9
+ * ExitPromptError ("Aborted by user") because the event loop stops
10
+ * waiting for stdin input.
11
+ */
12
+ function restoreStdin() {
13
+ const { stdin } = process;
14
+ if (typeof stdin.setRawMode === 'function') {
15
+ stdin.setRawMode(false);
16
+ }
17
+ stdin.resume();
18
+ stdin.ref();
19
+ }
20
+
5
21
  /**
6
22
  * Render the TUI commit selector.
7
23
  * @param {Array<{hash: string, subject: string}>} commits
@@ -11,6 +27,14 @@ import { App } from './App.js';
11
27
  */
12
28
  export function renderCommitSelector(commits, gitRawFn, { devBranch, mainBranch, since }) {
13
29
  return new Promise((resolve) => {
30
+ let resolved = false;
31
+ const settle = (val) => {
32
+ if (!resolved) {
33
+ resolved = true;
34
+ resolve(val);
35
+ }
36
+ };
37
+
14
38
  const { unmount, waitUntilExit } = render(
15
39
  createElement(App, {
16
40
  commits,
@@ -19,16 +43,18 @@ export function renderCommitSelector(commits, gitRawFn, { devBranch, mainBranch,
19
43
  mainBranch,
20
44
  since,
21
45
  onDone: (selectedHashes) => {
22
- resolve(selectedHashes);
46
+ settle(selectedHashes);
23
47
  },
24
48
  }),
25
49
  );
26
50
 
27
51
  waitUntilExit().then(() => {
52
+ restoreStdin();
28
53
  // Fallback: if exited without calling onDone, resolve with empty
29
- resolve([]);
54
+ settle([]);
30
55
  }).catch(() => {
31
- resolve([]);
56
+ restoreStdin();
57
+ settle([]);
32
58
  });
33
59
  });
34
60
  }