UNPKG

921 BJavaScriptView Raw
1'use strict';
2
3const async = require('async');
4
5exports.usage = '代码质量检测';
6exports.abbr = 'l';
7
8exports.setOptions = (optimist) => {
9 optimist.alias('d', 'dir');
10 optimist.describe('d', '检测特定目录/文件');
11};
12
13exports.run = function (options) {
14 let project = this.project,
15 dir = options.d || options.dir;
16
17 const lintFuncs = [
18 // 暂时只 lint js
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};