From 068653d0abd28d45b5b0b8f09a031765c7afd569 Mon Sep 17 00:00:00 2001 From: Jason Spafford Date: Mon, 24 Oct 2022 22:28:15 -0400 Subject: [PATCH] Fix OclifUX.ux.prompt() return type It's been a long standing issue that prompt returns a Promise when it clearly should return Promise. It's because the wrapper methods pauseAsync() don't forward their types along from the wrapped functions. --- src/cli-ux/action/base.ts | 2 +- src/cli-ux/prompt.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cli-ux/action/base.ts b/src/cli-ux/action/base.ts index b2b14191..522df8e0 100644 --- a/src/cli-ux/action/base.ts +++ b/src/cli-ux/action/base.ts @@ -92,7 +92,7 @@ export class ActionBase { task.status = status } - public async pauseAsync(fn: () => Promise, icon?: string) { + public async pauseAsync(fn: () => Promise, icon?: string): Promise { const task = this.task const active = task && task.active if (task && active) { diff --git a/src/cli-ux/prompt.ts b/src/cli-ux/prompt.ts index 7852a8a5..de66a3fd 100644 --- a/src/cli-ux/prompt.ts +++ b/src/cli-ux/prompt.ts @@ -120,9 +120,9 @@ function _prompt(name: string, inputOptions: Partial = {}): Prom * prompt for input * @param name - prompt text * @param options - @see IPromptOptions - * @returns void + * @returns Promise */ -export function prompt(name: string, options: IPromptOptions = {}) { +export function prompt(name: string, options: IPromptOptions = {}): Promise { return config.action.pauseAsync(() => { return _prompt(name, options) }, chalk.cyan('?')) @@ -149,9 +149,9 @@ export function confirm(message: string): Promise { /** * "press anykey to continue" * @param message - optional message to display to user - * @returns Promise + * @returns Promise */ -export async function anykey(message?: string): Promise { +export async function anykey(message?: string): Promise { const tty = Boolean(process.stdin.setRawMode) if (!message) { message = tty ?