mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(repl) add
This commit is contained in:
parent
3d017571ca
commit
df0ab548de
2 changed files with 32 additions and 0 deletions
|
|
@ -56,6 +56,10 @@
|
|||
case '--help':
|
||||
help();
|
||||
break;
|
||||
|
||||
case '--repl':
|
||||
repl();
|
||||
break;
|
||||
}
|
||||
|
||||
function version() {
|
||||
|
|
@ -100,4 +104,10 @@
|
|||
console.log('\n' + site);
|
||||
}
|
||||
|
||||
function repl() {
|
||||
console.log('REPL mode enabled (telnet localhost 1337)');
|
||||
require(DIR_LIB + '/server/repl');
|
||||
start();
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
22
lib/server/repl.js
Normal file
22
lib/server/repl.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var repl = require('repl'),
|
||||
net = require('net');
|
||||
|
||||
module.exports = net.createServer(function (socket) {
|
||||
var r = repl.start({
|
||||
prompt: '[' + process.pid + '] ' +socket.remoteAddress+':'+socket.remotePort+'> ',
|
||||
input: socket,
|
||||
output: socket,
|
||||
terminal: true,
|
||||
useGlobal: false
|
||||
});
|
||||
|
||||
r.on('exit', function () {
|
||||
socket.end();
|
||||
});
|
||||
r.context.socket = socket;
|
||||
}).listen(1337);
|
||||
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue