forked from csscomb/csscomb.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
34 lines (31 loc) · 957 Bytes
/
cli.js
File metadata and controls
34 lines (31 loc) · 957 Bytes
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
/**
* Command line implementation for CSScomb
*
* Usage example:
* ./node_modules/.bin/csscomb file1 [dir1 [fileN [dirN]]]
*/
var fs = require('fs');
var program = require('commander');
var vow = require('vow');
var Comb = require('./csscomb');
program
.version(require('../package.json').version)
.usage('[options] <file ...>')
.option('-c, --config [path]', 'configuration file path')
.parse(process.argv);
var comb = new Comb();
var configPath = program.config || (process.cwd() + '/.csscomb.json');
if (fs.existsSync(configPath)) {
comb.configure(require(configPath));
if (program.args.length > 0) {
vow.all(program.args.map(function(path) {
return comb.processPath(path);
})).fail(function(e) {
console.log('stack: ', e.stack);
process.exit(1);
});
}
} else {
console.log('Configuration file ' + configPath + ' was not found.');
process.exit(1);
}