This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
cli.js
63 lines (50 loc) 路 1.52 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
var async = require('async'),
chalk = require('chalk'),
program = require('commander'),
programOptions = require('./options'),
debug = require('./debug'),
dict = require('./dictionary'),
report = require('./report'),
tasks = require('./tasks'),
utils = require('./utils'),
_ = require('lodash'),
json,
jsonConfig,
jsonDefault = require('../.yaspellerrc.default.json'),
settings = {};
programOptions.set({ignoreTags: jsonDefault.ignoreTags.join(',')});
program.parse(process.argv);
jsonConfig = utils.getConfig(program.config);
json = _.assign(jsonDefault, jsonConfig);
chalk.enabled = program.colors;
debug.setDebug(program.debug);
var settings = {
excludeFiles: json.excludeFiles,
options: json.options || {}
};
['checkYo', 'fileExtensions', 'format', 'ignoreTags', 'lang', 'maxRequests'].forEach(function(key) {
settings[key] = program[key] || json[key];
});
programOptions.apiOptions.forEach(function(el) {
var key = el[0];
if(program[key]) {
settings.options[key] = true;
} else if(typeof json[key] !== 'undefined') {
settings.options[key] = json[key];
}
});
dict.set(program.dictionary, json.dictionary);
report.addReports(program.report || json.report);
if(process.stdin.isTTY && !program.args.length) {
program.help();
}
async.series(
process.stdin.isTTY ?
tasks.forResources(program.args, settings) :
tasks.forStdin(settings),
function() {
report.onend();
process.exit();
}
);