From 203fe8ee805743ef80c2ec176c96c92d584667c9 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Sun, 10 Jun 2018 06:00:13 -0700 Subject: [PATCH] fix: only timeout when set --- src/prompt.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/prompt.ts b/src/prompt.ts index b64b4a8a..318c6709 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -81,6 +81,8 @@ function normal(options: IPromptConfig, retries = 100): Promise { resolve(data || options.default) } }) - setTimeout(() => reject(), options.timeout || 10000).unref() + if (options.timeout) { + setTimeout(() => reject(new Error('timed out')), options.timeout).unref() + } }) }