1 | 'use strict';
|
2 |
|
3 | const async = require('async');
|
4 |
|
5 | exports.usage = '代码质量检测';
|
6 | exports.abbr = 'l';
|
7 |
|
8 | exports.setOptions = (optimist) => {
|
9 | optimist.alias('d', 'dir');
|
10 | optimist.describe('d', '检测特定目录/文件');
|
11 | };
|
12 |
|
13 | exports.run = function (options) {
|
14 | let project = this.project,
|
15 | dir = options.d || options.dir;
|
16 |
|
17 | const lintFuncs = [
|
18 |
|
19 | function(callback) {
|
20 | project.lint(dir, callback);
|
21 | }
|
22 | ];
|
23 |
|
24 | async.series(lintFuncs, (err, results) => {
|
25 | if (!err) {
|
26 | if (results[0] && results[1]) {
|
27 | success('All files complete without error.');
|
28 | process.exit(0);
|
29 | } else {
|
30 | process.exit(1);
|
31 | }
|
32 | } else if (err === true) {
|
33 | error('Lint Error');
|
34 | process.exit(1);
|
35 | } else {
|
36 | error(err);
|
37 | }
|
38 | });
|
39 | };
|