fix codestyle

pull/39/head
rcatoio 2015-02-04 16:45:03 +01:00
parent d8f9b491ea
commit 82618c8cc9
3 changed files with 16 additions and 4 deletions

View File

@ -5,7 +5,8 @@ var program = require('commander');
program
.version(require('../package.json').version)
.usage('[options] [file ...]')
.option('--remote-host <remote_host>', 'setting the remote host for a tail over ssh ( e.g: 192.168.0.2 )', String, null)
.option('--remote-host <remote_host>', 'setting the remote host for a tail over ssh ( e.g: 192.168.0.2 )', String,
null)
.option('--remote-user <remote_user>', 'setting the remote user for a tail over ssh, default: root', String, 'root')
.option('--remote-port <remote_port>', 'setting the remote port for a tail over ssh, default 22', Number, 22)
.option('-h, --host <host>', 'listening host, default 0.0.0.0', String, '0.0.0.0')

View File

@ -12,13 +12,24 @@ var Tail = function (path, options) {
this._buffer = new CBuffer(options.buffer);
var tail;
if(options && options.sshOptions && options.sshOptions.remoteHost) {
var args = [options.sshOptions.remoteUser+'@'+options.sshOptions.remoteHost,'-p', options.sshOptions.remotePort, '-t', 'tail -f '+path];
if (options && options.sshOptions && options.sshOptions.remoteHost) {
var args = [options.sshOptions.remoteUser + '@' + options.sshOptions.remoteHost, '-p',
options.sshOptions.remotePort, 'tail -f ' + path];
tail = spawn('ssh', args);
} else {
tail = spawn('tail', ['-n', options.buffer, '-F', path]);
}
tail.on('close', function () {
//kill the process if the tail is closed
process.exit();
});
tail.stderr.on('data', function (data) {
//if there is any error then display it in the console.
console.error(data.toString());
});
tail.stdout.on('data', function (data) {
var lines = data.toString('utf-8').split('\n');
lines.pop();

View File

@ -31,7 +31,7 @@ describe('connectBuilder', function () {
.expect(200, 'secret!', done);
});
it('should build app that setup session', function (done) {
it('should build app that setup session', function (done) {
var app = connectBuilder().session('secret', 'sessionkey').build();
app.use(function (req, res) {
res.end();