Skip to content

Commit

Permalink
adds backwards compatibility instead
Browse files Browse the repository at this point in the history
  • Loading branch information
a7ul committed May 8, 2021
1 parent b47e8ea commit bf1b5b7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import {existsSync} from 'fs'
import {exec, execSync} from 'child_process'
import {promisify} from 'util'
import {createInterface} from 'readline'
import {default as nodeFetch} from 'node-fetch'
import chalk from 'chalk'
Expand Down Expand Up @@ -102,7 +103,11 @@ export async function question(query, options) {
output: process.stdout,
completer,
})
const question = (q) => new Promise((resolve) => rl.question(q, resolve));
let question = promisify(rl.question).bind(rl)
if (!rl.question[promisify.custom]) {
// Backwards compatibility for node < v15.8.0
question = (q) => new Promise((resolve) => rl.question(q, resolve));
}
let answer = await question(query)
rl.close()
return answer
Expand Down

0 comments on commit bf1b5b7

Please sign in to comment.