1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- var __defProp = Object.defineProperty;
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
- // src/prompt.ts
- import { ListrPromptAdapter, ListrTaskEventType, ListrTaskState } from "listr2";
- var ListrInquirerPromptAdapter = class extends ListrPromptAdapter {
- static {
- __name(this, "ListrInquirerPromptAdapter");
- }
- prompt;
- /**
- * Get the current running instance of `inquirer`.
- */
- get instance() {
- return this.prompt;
- }
- /**
- * Create a new prompt with `inquirer`.
- */
- async run(prompt, ...[config, context]) {
- context ??= {};
- context.output ??= this.wrapper.stdout(ListrTaskEventType.PROMPT);
- this.reportStarted();
- this.task.on(ListrTaskEventType.STATE, (event) => {
- if (event === ListrTaskState.SKIPPED && this.prompt) {
- this.cancel();
- }
- });
- this.prompt = prompt(config, context);
- let result;
- try {
- result = await this.prompt;
- this.reportCompleted();
- } catch (e) {
- this.reportFailed();
- throw e;
- }
- return result;
- }
- /**
- * Cancel the ongoing prompt.
- */
- cancel() {
- if (!this.prompt) {
- return;
- }
- this.reportFailed();
- this.prompt.cancel();
- }
- };
- export {
- ListrInquirerPromptAdapter
- };
|