mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
24 lines
575 B
TypeScript
24 lines
575 B
TypeScript
|
|
||
|
const readline = require('readline/promises');
|
||
|
|
||
|
/* eslint-disable no-console */
|
||
|
|
||
|
let readlineInterface: any = null;
|
||
|
const waitForCliInput = async () => {
|
||
|
readlineInterface ??= readline.createInterface({
|
||
|
input: process.stdin,
|
||
|
output: process.stdout,
|
||
|
});
|
||
|
if (process.stdin.isTTY) {
|
||
|
const green = '\x1b[92m';
|
||
|
const reset = '\x1b[0m';
|
||
|
await readlineInterface.question(`${green}[Press enter to continue]${reset}`);
|
||
|
|
||
|
console.log('Continuing...');
|
||
|
} else {
|
||
|
console.warn('Input is not from a TTY -- not waiting for input.');
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export default waitForCliInput;
|