@inquirer/core 2.2.0 → 2.3.1

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/README.md CHANGED
@@ -51,7 +51,7 @@ const confirm = createPrompt<boolean, { message: string; default?: boolean }>(
51
51
 
52
52
  const message = chalk.bold(config.message);
53
53
  return `${prefix} ${message}${defaultValue} ${formattedValue}`;
54
- }
54
+ },
55
55
  );
56
56
 
57
57
  /**
package/dist/cjs/index.js CHANGED
@@ -136,8 +136,9 @@ exports.useRef = useRef;
136
136
  function createPrompt(view) {
137
137
  const prompt = (config, context) => {
138
138
  var _a, _b;
139
- // Set our state before starting the prompt.
140
- resetHookState();
139
+ if (sessionRl) {
140
+ throw new Error('An inquirer prompt is already running.\nMake sure you await the result of the previous prompt before calling another prompt.');
141
+ }
141
142
  // Default `input` to stdin
142
143
  const input = (_a = context === null || context === void 0 ? void 0 : context.input) !== null && _a !== void 0 ? _a : process.stdin;
143
144
  // Add mute capabilities to the output
@@ -168,6 +169,7 @@ function createPrompt(view) {
168
169
  screen.clearContent();
169
170
  }
170
171
  screen.done();
172
+ resetHookState();
171
173
  process.removeListener('SIGINT', onForceExit);
172
174
  };
173
175
  cancel = () => {
@@ -205,12 +207,16 @@ function createPrompt(view) {
205
207
  screen.render(content, bottomContent);
206
208
  }
207
209
  catch (err) {
210
+ onExit();
208
211
  reject(err);
209
212
  }
210
213
  };
211
214
  // TODO: we should display a loader while we get the default options.
212
215
  (0, options_mjs_1.getPromptConfig)(config).then(workLoop, reject);
213
216
  });
217
+ answer.catch(() => {
218
+ resetHookState();
219
+ });
214
220
  answer.cancel = cancel;
215
221
  return answer;
216
222
  };
@@ -3,10 +3,10 @@
3
3
  import readline from 'node:readline';
4
4
  import { type Prompt } from '@inquirer/type';
5
5
  import MuteStream from 'mute-stream';
6
- export { usePrefix } from './lib/prefix.d.cts';
7
- export * from './lib/key.d.cts';
8
- export * from './lib/Paginator.d.cts';
9
- export * from './lib/Separator.d.cts';
6
+ export { usePrefix } from './lib/prefix.js';
7
+ export * from './lib/key.js';
8
+ export * from './lib/Paginator.js';
9
+ export * from './lib/Separator.js';
10
10
  export type InquirerReadline = readline.ReadLine & {
11
11
  output: MuteStream;
12
12
  input: NodeJS.ReadableStream;
@@ -1,2 +1,2 @@
1
- import type { AsyncPromptConfig, ResolvedPromptConfig } from '../index.d.cts';
1
+ import type { AsyncPromptConfig, ResolvedPromptConfig } from '../index.js';
2
2
  export declare function getPromptConfig<In extends AsyncPromptConfig>(option: In): Promise<In & ResolvedPromptConfig>;
@@ -1,4 +1,4 @@
1
- import { InquirerReadline } from '../index.d.cts';
1
+ import { InquirerReadline } from '../index.js';
2
2
  export default class ScreenManager {
3
3
  private readonly rl;
4
4
  private height;
@@ -110,8 +110,9 @@ export function useRef(val) {
110
110
  }
111
111
  export function createPrompt(view) {
112
112
  const prompt = (config, context) => {
113
- // Set our state before starting the prompt.
114
- resetHookState();
113
+ if (sessionRl) {
114
+ throw new Error('An inquirer prompt is already running.\nMake sure you await the result of the previous prompt before calling another prompt.');
115
+ }
115
116
  // Default `input` to stdin
116
117
  const input = context?.input ?? process.stdin;
117
118
  // Add mute capabilities to the output
@@ -142,6 +143,7 @@ export function createPrompt(view) {
142
143
  screen.clearContent();
143
144
  }
144
145
  screen.done();
146
+ resetHookState();
145
147
  process.removeListener('SIGINT', onForceExit);
146
148
  };
147
149
  cancel = () => {
@@ -179,12 +181,16 @@ export function createPrompt(view) {
179
181
  screen.render(content, bottomContent);
180
182
  }
181
183
  catch (err) {
184
+ onExit();
182
185
  reject(err);
183
186
  }
184
187
  };
185
188
  // TODO: we should display a loader while we get the default options.
186
189
  getPromptConfig(config).then(workLoop, reject);
187
190
  });
191
+ answer.catch(() => {
192
+ resetHookState();
193
+ });
188
194
  answer.cancel = cancel;
189
195
  return answer;
190
196
  };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@inquirer/core",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "engines": {
5
5
  "node": ">=14.18.0"
6
6
  },
7
7
  "description": "Core Inquirer prompt API",
8
8
  "main": "./dist/cjs/index.js",
9
- "typings": "./dist/cjs/types/index.d.cts",
9
+ "typings": "./dist/cjs/types/index.d.ts",
10
10
  "files": [
11
11
  "dist/**/*"
12
12
  ],
@@ -57,7 +57,10 @@
57
57
  "license": "MIT",
58
58
  "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/core/README.md",
59
59
  "dependencies": {
60
- "@inquirer/type": "^1.1.0",
60
+ "@inquirer/type": "^1.1.1",
61
+ "@types/mute-stream": "^0.0.1",
62
+ "@types/node": "^20.4.2",
63
+ "@types/wrap-ansi": "^3.0.0",
61
64
  "ansi-escapes": "^4.3.2",
62
65
  "chalk": "^4.1.2",
63
66
  "cli-spinners": "^2.8.0",
@@ -70,7 +73,7 @@
70
73
  "wrap-ansi": "^6.0.1"
71
74
  },
72
75
  "devDependencies": {
73
- "@inquirer/testing": "^2.0.0"
76
+ "@inquirer/testing": "^2.1.1"
74
77
  },
75
78
  "scripts": {
76
79
  "tsc": "yarn run clean && yarn run tsc:esm && yarn run tsc:cjs",
@@ -89,10 +92,10 @@
89
92
  "default": "./dist/esm/index.mjs"
90
93
  },
91
94
  "require": {
92
- "types": "./dist/cjs/types/index.d.cts",
95
+ "types": "./dist/cjs/types/index.d.ts",
93
96
  "default": "./dist/cjs/index.js"
94
97
  }
95
98
  }
96
99
  },
97
- "gitHead": "ba98109480c442d261f243e4117243a9e2f12fd0"
100
+ "gitHead": "b1b29c0b6da9420d739cd46704c205515de2db04"
98
101
  }
File without changes
File without changes