mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
fix(cloudcmd) --console, --config-dialog: defaults
This commit is contained in:
parent
e8f91f4908
commit
eddb8bec4a
4 changed files with 44 additions and 9 deletions
|
|
@ -49,9 +49,9 @@ const args = require('minimist')(argv.slice(2), {
|
|||
root : config('root') || '/',
|
||||
prefix : config('prefix') || '',
|
||||
progress : config('progress'),
|
||||
console : defaultTrue(config('console')),
|
||||
console : config('console'),
|
||||
|
||||
'config-dialog': defaultTrue(config('configDialog')),
|
||||
'config-dialog': config('configDialog'),
|
||||
'one-panel-mode': config('onePanelMode'),
|
||||
},
|
||||
alias: {
|
||||
|
|
@ -116,13 +116,6 @@ if (args.version) {
|
|||
});
|
||||
}
|
||||
|
||||
function defaultTrue(value) {
|
||||
if (typeof value === 'undefined')
|
||||
return true;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function validateRoot(root) {
|
||||
const validate = require('../lib/server/validate');
|
||||
validate.root(root, console.log);
|
||||
|
|
|
|||
|
|
@ -78,12 +78,22 @@ module.exports = function(params) {
|
|||
config(name, value);
|
||||
});
|
||||
|
||||
config('console', defaultTrue(options.console));
|
||||
config('configDialog', defaultTrue(options.configDialog));
|
||||
|
||||
if (p.socket)
|
||||
listen(prefix, p.socket);
|
||||
|
||||
return cloudcmd(prefix);
|
||||
};
|
||||
|
||||
function defaultTrue(value) {
|
||||
if (typeof value === 'undefined')
|
||||
return true;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function authCheck(socket, success) {
|
||||
if (!config('auth'))
|
||||
return success();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,19 @@ const io = require('socket.io-client');
|
|||
|
||||
const before = require('./before');
|
||||
|
||||
test('cloudcmd: console: enabled by default', (t) => {
|
||||
before({}, (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: enabled', (t) => {
|
||||
const config = {console: true};
|
||||
|
||||
|
|
|
|||
|
|
@ -99,3 +99,22 @@ test('cloudcmd: rest: config: patch: no configDialog: statusCode', (t) => {
|
|||
});
|
||||
});
|
||||
|
||||
test('cloudcmd: rest: config: enabled by default', (t) => {
|
||||
before({}, (port, after) => {
|
||||
const json = {
|
||||
auth: false,
|
||||
};
|
||||
|
||||
patch(`http://localhost:${port}/api/v1/config`, json)
|
||||
.then(warp(_pullout, 'string'))
|
||||
.then((result) => {
|
||||
t.equal(result, 'config: ok("auth")', 'should patch config');
|
||||
t.end();
|
||||
after();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue