1 | 'use strict';
|
2 |
|
3 | var util = require('util');
|
4 | var path = require('path');
|
5 | var utils = require('../utils');
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | module.exports = function(app, base, options) {
|
18 | return function(val, key, config, schema) {
|
19 | if (typeof val === 'undefined') {
|
20 | return;
|
21 | }
|
22 |
|
23 |
|
24 | if (utils.isObject(val)) {
|
25 | val = utils.stringify(val);
|
26 | }
|
27 |
|
28 | if (typeof val === 'string') {
|
29 | return path.resolve(val);
|
30 | }
|
31 |
|
32 | if (typeof val === 'boolean') {
|
33 | val = config[key] = { show: true };
|
34 | return val;
|
35 | }
|
36 |
|
37 | val = util.inspect(val);
|
38 | throw new TypeError('--toc: expected a string or boolean, but received: ' + val);
|
39 | };
|
40 | };
|