Skip to content

Commit e89eca4

Browse files
committed
Main class preparation
1 parent c366ccb commit e89eca4

2 files changed

Lines changed: 38 additions & 9 deletions

File tree

lib/cli.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ program
1313
.option('-c, --config [path]', 'configuration file path')
1414
.parse(process.argv);
1515

16-
var configPath = program.config || (process.cwd() + '/.csscomb.json');
16+
var Comb = require('./csscomb'),
17+
comb = new Comb(),
18+
configPath = program.config || (process.cwd() + '/.csscomb.json');
1719

18-
/**
19-
* Trying to load config.
20-
* Custom config path can be specified using '-c' option.
21-
*/
2220
if (fs.existsSync(configPath)) {
23-
var config = require(configPath);
21+
comb.configure(require(configPath));
2422
} else {
2523
console.log('Configuration file ' + configPath + ' was not found.');
26-
/**
27-
* Quitting with 1 error code.
28-
*/
2924
process.exit(1);
3025
}

lib/csscomb.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Starts Code Style checking process.
3+
*
4+
* @name Comb
5+
*/
6+
var Comb = function() {
7+
this._rules = {
8+
'colon-space': {},
9+
'rule-indent': {},
10+
'stick-brace': {},
11+
'sort-order': {}
12+
},
13+
this._config = {};
14+
this._excludes = null;
15+
};
16+
17+
Comb.prototype = {
18+
19+
/**
20+
* Loads configuration from JSON.
21+
*
22+
* @param {Object} config
23+
*/
24+
configure: function(config) {
25+
for (var rule in config) {
26+
if (config.hasOwnProperty(rule) && this._rules[rule]) {
27+
this._config[rule] = config[rule];
28+
}
29+
}
30+
}
31+
32+
};
33+
34+
module.exports = Comb;

0 commit comments

Comments
 (0)