forked from IBM/tekton-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner.js
28 lines (25 loc) · 868 Bytes
/
runner.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
const fs = require('fs');
const path = require('path');
const yaml = require('yaml');
const collector = require('./Collector');
const Reporter = require('./reporter');
const rules = require('./rules');
const getRulesConfig = () => {
let rcFile;
if (fs.existsSync('./.tektonlintrc.yaml')) {
rcFile = fs.readFileSync('./.tektonlintrc.yaml', 'utf8');
} else {
rcFile = fs.readFileSync(path.resolve(__dirname, '.tektonlintrc.yaml'), 'utf8');
}
return yaml.parse(rcFile);
};
module.exports = async function runner(globs) {
const docs = await collector(globs);
const reporter = new Reporter(docs);
return module.exports.lint(docs.map(doc => doc.content), reporter);
};
module.exports.lint = function lint(docs, reporter) {
reporter = reporter || new Reporter();
const config = getRulesConfig();
return rules.lint(docs, reporter, config);
};