-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathchecker.js
33 lines (28 loc) · 961 Bytes
/
checker.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
const Promise = require('bluebird');
const _ = require('lodash');
const requireDir = require('require-dir');
const readTheme = require('./read-theme');
const versions = require('./utils').versions;
const checks = requireDir('./checks');
/**
* Check theme
*
* Takes a theme path, reads the theme, and checks it for issues.
* Returns a theme object.
* @param themePath
* @param options
* @returns {Object}
*/
const checker = function checkAll(themePath, options) {
options = options || {};
const passedVersion = _.get(options, 'checkVersion', 'latest');
return readTheme(themePath)
.then(function (theme) {
// set the major version to check
theme.checkedVersion = versions[passedVersion].major;
return Promise.reduce(_.values(checks), function (theme, check) {
return check(theme, options, themePath);
}, theme);
});
};
module.exports = checker;