mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(cloudcmd) --no-console: console is always enabled (#99)
This commit is contained in:
parent
485923abd7
commit
4b8f772538
3 changed files with 37 additions and 6 deletions
|
|
@ -45,8 +45,8 @@ module.exports = function(params) {
|
|||
const p = params || {};
|
||||
const options = p.config || {};
|
||||
const plugins = p.plugins;
|
||||
|
||||
const keys = Object.keys(options);
|
||||
|
||||
let prefix;
|
||||
|
||||
checkPlugins(plugins);
|
||||
|
|
@ -76,8 +76,11 @@ module.exports = function(params) {
|
|||
config(name, value);
|
||||
});
|
||||
|
||||
config('console', defaultTrue(options.console));
|
||||
config('configDialog', defaultTrue(options.configDialog));
|
||||
const console = config('console');
|
||||
const configDialog = config('configDialog');
|
||||
|
||||
config('console', defaultValue(options.console, console));
|
||||
config('configDialog', defaultValue(options.configDialog, configDialog));
|
||||
|
||||
if (p.socket)
|
||||
listen(prefix, p.socket);
|
||||
|
|
@ -85,9 +88,9 @@ module.exports = function(params) {
|
|||
return cloudcmd(prefix, plugins);
|
||||
};
|
||||
|
||||
function defaultTrue(value) {
|
||||
function defaultValue(value, previous) {
|
||||
if (typeof value === 'undefined')
|
||||
return true;
|
||||
return previous;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('tape');
|
||||
const cloudcmd = require('../../lib/cloudcmd');
|
||||
const DIR = '../../lib/';
|
||||
const cloudcmd = require(DIR + 'cloudcmd');
|
||||
const config = require(DIR + 'server/config');
|
||||
|
||||
test('cloudcmd: args: no', (t) => {
|
||||
const fn = () => cloudcmd();
|
||||
|
|
@ -19,3 +21,27 @@ test('cloudcmd: args: plugins: error', (t) => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: defaults: config', (t) => {
|
||||
const configDialog = config('configDialog');
|
||||
|
||||
config('configDialog', false);
|
||||
cloudcmd();
|
||||
t.notOk(config('configDialog'), 'should not override config with defaults');
|
||||
|
||||
config('configDialog', configDialog);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: defaults: console', (t) => {
|
||||
const console = config('console');
|
||||
|
||||
config('console', false);
|
||||
cloudcmd();
|
||||
t.notOk(config('console'), 'should not override config with defaults');
|
||||
|
||||
config('console', console);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const test = require('tape');
|
|||
const promisify = require('es6-promisify');
|
||||
const pullout = require('pullout');
|
||||
const request = require('request');
|
||||
const manageConfig = require('../../lib/server/config');
|
||||
|
||||
const before = require('../before');
|
||||
|
||||
|
|
@ -93,6 +94,7 @@ test('cloudcmd: rest: config: patch: no configDialog: statusCode', (t) => {
|
|||
.then((result) => {
|
||||
result.on('response', (response) => {
|
||||
t.equal(response.statusCode, 404);
|
||||
manageConfig('configDialog', true);
|
||||
t.end();
|
||||
after();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue