Skip to content

Commit a28337c

Browse files
committed
Merge pull request #71 from anton-rudeshko/welcome-fb
Small changes, typos and issues.
2 parents 900e565 + 04bb00d commit a28337c

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
node_modules
2+
3+
.idea
4+
*.iml

lib/cli.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Command line implementation for CSScomb
2+
* Command line implementation for CSSComb
33
*
44
* Usage example:
55
* ./node_modules/.bin/csscomb file1 [dir1 [fileN [dirN]]]
@@ -15,19 +15,22 @@ program
1515
.option('-c, --config [path]', 'configuration file path')
1616
.parse(process.argv);
1717

18-
var comb = new Comb();
18+
if (!program.args.length) {
19+
console.log('No input paths specified');
20+
program.help();
21+
}
22+
1923
var configPath = program.config || (process.cwd() + '/.csscomb.json');
2024

2125
if (fs.existsSync(configPath)) {
26+
var comb = new Comb();
2227
comb.configure(require(configPath));
23-
if (program.args.length > 0) {
24-
vow.all(program.args.map(function(path) {
25-
return comb.processPath(path);
26-
})).fail(function(e) {
27-
console.log('stack: ', e.stack);
28-
process.exit(1);
29-
});
30-
}
28+
vow.all(program.args.map(function(path) {
29+
return comb.processPath(path);
30+
})).fail(function(e) {
31+
console.log('stack: ', e.stack);
32+
process.exit(1);
33+
});
3134
} else {
3235
console.log('Configuration file ' + configPath + ' was not found.');
3336
process.exit(1);

lib/csscomb.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ var vfs = require('vow-fs');
66
/**
77
* Starts Code Style processing process.
88
*
9+
* @constructor
910
* @name Comb
1011
*/
1112
var Comb = function() {
12-
this._handlers;
1313
this._options = [
1414
'always-semicolon',
1515
'color-case',
@@ -24,7 +24,6 @@ var Comb = function() {
2424
'unitless-zero',
2525
'sort-order'
2626
];
27-
this._config = {};
2827
this._exclude = null;
2928
};
3029

@@ -37,17 +36,18 @@ Comb.prototype = {
3736
* @param {Object} config
3837
*/
3938
configure: function(config) {
40-
var _this = this;
4139
this._handlers = [];
4240
this._options.forEach(function(option) {
43-
if (config[option] !== undefined) {
44-
try {
45-
var handler = require('./options/' + option).setValue(config[option]);
46-
handler && _this._handlers.push(handler);
47-
} catch (e) {
48-
}
41+
if (typeof config[option] === 'undefined') return;
42+
43+
try {
44+
var handler = require('./options/' + option).setValue(config[option]);
45+
handler && this._handlers.push(handler);
46+
} catch (e) {
47+
console.warn('Error loading "%s" handler: %s', option, e.message);
4948
}
50-
});
49+
}, this);
50+
5151
this._exclude = (config.exclude || []).map(function(pattern) {
5252
return new minimatch.Minimatch(pattern);
5353
});
@@ -151,7 +151,7 @@ Comb.prototype = {
151151
},
152152

153153
/**
154-
* Processs directory or file.
154+
* Process directory or file.
155155
*
156156
* @param {String} path
157157
*/
@@ -177,7 +177,7 @@ Comb.prototype = {
177177
},
178178

179179
/**
180-
* Returns true if specified path is not in exluded list.
180+
* Returns true if specified path is not in excluded list.
181181
*
182182
* @returns {Boolean}
183183
*/

0 commit comments

Comments
 (0)