mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(cloudcmd) add ability to disable console with "--no-console" (#65)
This commit is contained in:
parent
6b26b26115
commit
c3c008ff72
12 changed files with 79 additions and 14 deletions
|
|
@ -4,6 +4,7 @@ const http = require('http');
|
|||
const os = require('os');
|
||||
|
||||
const express = require('express');
|
||||
const io = require('socket.io');
|
||||
const writejson = require('writejson');
|
||||
const readjson = require('readjson');
|
||||
|
||||
|
|
@ -23,7 +24,10 @@ module.exports = (config, fn = config) => {
|
|||
server.close();
|
||||
};
|
||||
|
||||
const socket = io.listen(server);
|
||||
|
||||
app.use(cloudcmd({
|
||||
socket,
|
||||
config: assign(defaultConfig(), config)
|
||||
}));
|
||||
|
||||
|
|
|
|||
37
test/console.js
Normal file
37
test/console.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('tape');
|
||||
const io = require('socket.io-client');
|
||||
|
||||
const before = require('./before');
|
||||
|
||||
test('cloudcmd: console: enabled', (t) => {
|
||||
const config = {console: true};
|
||||
|
||||
before(config, (port, after) => {
|
||||
const socket = io(`http://localhost:${port}/console`)
|
||||
|
||||
socket.once('data', (data) => {
|
||||
socket.close();
|
||||
t.equal(data, 'client #1 console connected\n', 'should emit data event');
|
||||
after();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('cloudcmd: console: disabled', (t) => {
|
||||
const config = {console: false};
|
||||
|
||||
before(config, (port, after) => {
|
||||
const socket = io(`http://localhost:${port}/console`);
|
||||
|
||||
socket.on('error', (error) => {
|
||||
t.equal(error, 'Invalid namespace', 'should emit error');
|
||||
socket.close();
|
||||
after();
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue