-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
57 lines (46 loc) · 1.26 KB
/
index.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
/**
* @file main file
* @author nighca<[email protected]>
*/
var fs = require('fs');
var config = require('./lib/config');
var htmlcs = require('./lib/htmlcs');
/**
* Do hint with given filePath & option for readFile.
*
* @param {string} filePath - path of the target file
* @param {Object=} options - option for readFile
* @return {Report[]} the hint result, list of reports
*/
var hintFile = function (filePath, options) {
options = options || {
encoding: 'utf-8'
};
var cnt = fs.readFileSync(filePath, options);
var cfg = config.load(filePath);
return htmlcs.hint(cnt, cfg);
};
/**
* Do format with given filePath & option for readFile
*
* @param {string} filePath - path of the target file
* @param {Object=} options - option for readFile
* @return {string} the formatted code
*/
var formatFile = function (filePath, options) {
options = options || {
encoding: 'utf-8'
};
var cnt = fs.readFileSync(filePath, options);
var cfg = config.load(filePath);
return htmlcs.format(cnt, cfg);
};
module.exports = {
addRule: htmlcs.addRule,
hint: htmlcs.hint,
hintAsync: htmlcs.hintAsync,
format: htmlcs.format,
formatAsync: htmlcs.formatAsync,
hintFile: hintFile,
formatFile: formatFile
};