Skip to content

Commit 0f61b90

Browse files
committed
Verbose mode update
1 parent ace82c4 commit 0f61b90

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ Available value: `{Boolean}` `true`
6666
Config mode: `{ "verbose": true }`
6767
```bash
6868
$ ./bin/csscomb ./test
69-
./test/integral.expect.css
70-
./test/integral.origin.css
69+
✓ test/integral.origin.css
70+
test/integral.expect.css
71+
7172
2 files processed
72-
94 ms spent
73+
1 file fixed
74+
96 ms spent
7375
```
7476
7577
CLI mode:

lib/cli.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ if (fs.existsSync(configPath)) {
3636
process.exit(1);
3737
}).always(function() {
3838
if (config.verbose) {
39-
console.log(comb.count + ' file' + (comb.count === 1 ? '' : 's') + ' processed');
39+
console.log('');
40+
console.log(comb.processed + ' file' + (comb.processed === 1 ? '' : 's') + ' processed');
41+
console.log(comb.changed + ' file' + (comb.changed === 1 ? '' : 's') + ' fixed');
4042
console.log((new Date().getTime() - time.getTime()) + ' ms spent');
4143
}
4244
});

lib/csscomb.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ Comb.prototype = {
5454
return new minimatch.Minimatch(pattern);
5555
});
5656

57-
this.count = 0;
57+
this.processed = 0;
58+
this.changed = 0;
5859
this._verbose = config.verbose;
5960
},
6061

@@ -119,9 +120,12 @@ Comb.prototype = {
119120
var _this = this;
120121
if (this._shouldProcess(path) && path.match(/\.css$/)) {
121122
return vfs.read(path, 'utf8').then(function(data) {
122-
return vfs.write(path, _this.processString(data, path), 'utf8').then(function() {
123-
_this.count++;
124-
if (_this._verbose) console.log(path);
123+
var processedData = _this.processString(data, path);
124+
var changed = data !== processedData;
125+
return vfs.write(path, processedData, 'utf8').then(function() {
126+
_this.processed++;
127+
if (changed) _this.changed++;
128+
if (_this._verbose) console.log((changed ? '✓' : ' ') + ' ' + path);
125129
});
126130
});
127131
}

0 commit comments

Comments
 (0)