Last active
October 20, 2020 07:38
-
-
Save Estecka/c349f3a383b27027fd19955c9ae7755e to your computer and use it in GitHub Desktop.
Tiny Javascript Command Line Interface for NodeJS
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
console.log("Welcome, master"); | |
var readline = require('readline'); | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
terminal: true | |
}); | |
rl.on('line', function(line){ | |
if (line == "exit") | |
return rl.close(); | |
try { | |
var r = eval(line); | |
console.log(r); | |
} catch (e) { | |
console.log(e); | |
} | |
}) | |
function load (module){ | |
global[module] = require("./"+module+"/index.js"); | |
return module; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment