1 | var common = require('./common');
|
2 |
|
3 | common.register('set', _set, {
|
4 | allowGlobbing: false,
|
5 | wrapOutput: false,
|
6 | });
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function _set(options) {
|
25 | if (!options) {
|
26 | var args = [].slice.call(arguments, 0);
|
27 | if (args.length < 2) common.error('must provide an argument');
|
28 | options = args[1];
|
29 | }
|
30 | var negate = (options[0] === '+');
|
31 | if (negate) {
|
32 | options = '-' + options.slice(1);
|
33 | }
|
34 | options = common.parseOptions(options, {
|
35 | 'e': 'fatal',
|
36 | 'v': 'verbose',
|
37 | 'f': 'noglob',
|
38 | });
|
39 |
|
40 | if (negate) {
|
41 | Object.keys(options).forEach(function (key) {
|
42 | options[key] = !options[key];
|
43 | });
|
44 | }
|
45 |
|
46 | Object.keys(options).forEach(function (key) {
|
47 |
|
48 |
|
49 | if (negate !== options[key]) {
|
50 | common.config[key] = options[key];
|
51 | }
|
52 | });
|
53 | return;
|
54 | }
|
55 | module.exports = _set;
|