Created
August 31, 2016 07:18
-
-
Save aGuyNamedJonas/537781ce136135694046bc8944fd7987 to your computer and use it in GitHub Desktop.
Simple interactive node.js script to have users continuously enter input.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken from: | |
// http://stackoverflow.com/questions/24464404/how-to-readline-infinitely-in-node-js | |
const readline = require('readline'); | |
var log = console.log; | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
function searchPrompt() { | |
rl.question('cmd> ', input => { | |
if( input == 'exit' ) | |
return rl.close(); | |
log('You entered: ', input); | |
searchPrompt(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment