Skip to content

Fix callback invocation for readline.question #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Breaking changes:
New features:

Bugfixes:
- Ensure that callbacks passed to `question` and `question'` are invoked
- Fixed typo in options passed to `readline.createInterface`

Other improvements:

Expand Down
2 changes: 1 addition & 1 deletion src/Node/ReadLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const createInterfaceImpl = (options) => readline.createInterface({
historySize: options.historySize,
removeHistoryDuplicates: options.removeHistoryDuplicates,
prompt: options.prompt,
crlDelay: options.crlDelay,
crlfDelay: options.crlfDelay,
escapeCodeTimeout: options.escapeCodeTimeout,
tabSize: options.tabSize,
signal: options.signal
Expand Down
8 changes: 4 additions & 4 deletions src/Node/ReadLine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ foreign import promptOptsImpl :: EffectFn2 (Boolean) (Interface) (Unit)
-- |
-- | The callback function passed to `rl.question()` does not follow the typical pattern of accepting an Error object or null as the first argument. The callback is called with the provided answer as the only argument.
question :: String -> (String -> Effect Unit) -> Interface -> Effect Unit
question text cb iface = runEffectFn3 questionImpl iface text cb
question text cb iface = runEffectFn3 questionImpl iface text $ mkEffectFn1 cb

foreign import questionImpl :: EffectFn3 (Interface) (String) ((String -> Effect Unit)) Unit
foreign import questionImpl :: EffectFn3 (Interface) (String) (EffectFn1 String Unit) Unit

-- | Writes a query to the output, waits
-- | for user input to be provided on input, then invokes
Expand All @@ -338,9 +338,9 @@ foreign import questionImpl :: EffectFn3 (Interface) (String) ((String -> Effect
-- |
-- | The callback function passed to `rl.question()` does not follow the typical pattern of accepting an Error object or null as the first argument. The callback is called with the provided answer as the only argument.
question' :: String -> { signal :: AbortSignal } -> (String -> Effect Unit) -> Interface -> Effect Unit
question' text opts cb iface = runEffectFn4 questionOptsCbImpl iface text opts cb
question' text opts cb iface = runEffectFn4 questionOptsCbImpl iface text opts $ mkEffectFn1 cb

foreign import questionOptsCbImpl :: EffectFn4 (Interface) (String) { signal :: AbortSignal } ((String -> Effect Unit)) Unit
foreign import questionOptsCbImpl :: EffectFn4 (Interface) (String) { signal :: AbortSignal } (EffectFn1 String Unit) Unit

-- | The rl.resume() method resumes the input stream if it has been paused.
resume :: Interface -> Effect Unit
Expand Down