UNPKG

603 BJavaScriptView Raw
1'use strict';
2
3var utils = require('../utils');
4
5module.exports = function(app, base, argv) {
6 return function(val, key, config, schema) {
7 if (typeof val === 'undefined') {
8 return;
9 }
10
11 if (typeof val === 'boolean') {
12 val = { show: val };
13 }
14
15 if (typeof val === 'string') {
16 var obj = {};
17 obj[val] = true;
18 val = config[key] = obj;
19 }
20
21 if (!utils.isObject(val)) {
22 delete config[key];
23 return;
24 }
25
26 schema.update('options', config);
27 config.options = utils.merge({}, config.options, val);
28 schema.omit(key);
29 return;
30 };
31};