1 | const documentation = require('../');
|
2 | const fs = require('fs');
|
3 | const path = require('path');
|
4 | const sharedOptions = require('./shared_options');
|
5 |
|
6 |
|
7 |
|
8 | module.exports.command = 'lint [input..]';
|
9 | module.exports.description = 'check for common style and uniformity mistakes';
|
10 | module.exports.builder = {
|
11 | shallow: sharedOptions.sharedInputOptions.shallow
|
12 | };
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | module.exports.handler = function(argv) {
|
23 | argv._handled = true;
|
24 | if (!argv.input.length) {
|
25 | try {
|
26 | argv.input = [
|
27 | JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'))
|
28 | .main || 'index.js'
|
29 | ];
|
30 | } catch (e) {
|
31 | throw new Error(
|
32 | 'documentation was given no files and was not run in a module directory'
|
33 | );
|
34 | }
|
35 | }
|
36 | documentation
|
37 | .lint(argv.input, argv)
|
38 | .then(lintOutput => {
|
39 | if (lintOutput) {
|
40 | console.log(lintOutput);
|
41 | process.exit(1);
|
42 | } else {
|
43 | process.exit(0);
|
44 | }
|
45 | })
|
46 | .catch(err => {
|
47 |
|
48 | console.error(err);
|
49 | process.exit(1);
|
50 | });
|
51 | };
|