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 |
|
25 | function _set(options) {
|
26 | if (!options) {
|
27 | var args = [].slice.call(arguments, 0);
|
28 | if (args.length < 2) common.error('must provide an argument');
|
29 | options = args[1];
|
30 | }
|
31 | var negate = (options[0] === '+');
|
32 | if (negate) {
|
33 | options = '-' + options.slice(1);
|
34 | }
|
35 | options = common.parseOptions(options, {
|
36 | 'e': 'fatal',
|
37 | 'v': 'verbose',
|
38 | 'f': 'noglob',
|
39 | });
|
40 |
|
41 | if (negate) {
|
42 | Object.keys(options).forEach(function (key) {
|
43 | options[key] = !options[key];
|
44 | });
|
45 | }
|
46 |
|
47 | Object.keys(options).forEach(function (key) {
|
48 |
|
49 |
|
50 | if (negate !== options[key]) {
|
51 | common.config[key] = options[key];
|
52 | }
|
53 | });
|
54 | return;
|
55 | }
|
56 | module.exports = _set;
|