From 933df4d93111ece0131867fb9dffb4b379c69b14 Mon Sep 17 00:00:00 2001 From: Adam Stolcenburg Date: Tue, 7 Apr 2026 21:05:45 +0200 Subject: [PATCH] Fix compatibility with node.js v16 node:readline/promises is avaialble from node.js v17 --- bolt/src/fetch.cjs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bolt/src/fetch.cjs b/bolt/src/fetch.cjs index 062fbae..e7556d5 100644 --- a/bolt/src/fetch.cjs +++ b/bolt/src/fetch.cjs @@ -21,7 +21,7 @@ const http = require('node:http'); const https = require('node:https'); const fs = require('node:fs'); const path = require('node:path'); -const readline = require('node:readline/promises'); +const readline = require('node:readline'); const { Transform } = require('node:stream'); const { pipeline } = require('node:stream/promises'); const { spawnSync } = require('node:child_process'); @@ -131,16 +131,20 @@ function postJSON(url, body) { }); } +function question(rl, prompt) { + return new Promise((resolve) => rl.question(prompt, resolve)); +} + async function promptCredentials(username) { if (!process.stdin.isTTY) { throw new Error('Cannot prompt for credentials: stdin is not a terminal'); } const rl = readline.createInterface({ input: process.stdin, output: process.stderr, terminal: false }); try { - username = username || await rl.question('Username: '); + username = username || await question(rl, 'Username: '); const echoOff = spawnSync('stty', ['-echo'], { stdio: 'inherit' }).status === 0; try { - const password = await rl.question('Password: '); + const password = await question(rl, 'Password: '); if (echoOff) process.stderr.write('\n'); return { username, password }; } finally {