summary refs log tree commit diff
path: root/scripts/utils/ask.js
blob: 4dcd88e2263a7a294cc1eada77d29a498e6992c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });

async function ask(question) {
	return new Promise((resolve, _reject) => {
		return rl.question(question, (answer) => {
			resolve(answer);
		});
	}).catch((err) => {
		console.log(err);
	});
}
async function askBool(question) {
	return /y?/i.test(await ask(question));
}

module.exports = {
	ask,
	askBool
};