-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (24 loc) · 897 Bytes
/
index.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
var cs = require('..'); // that's our css-specs lib
var fs = require('fs');
var log = cs.logger('example', 'yellow');
var timer = log.timer('full run', 'magenta');
var cssBuildPath = 'example.css';
var url = './example.html';
// url = 'http://perdu.com/';
// cssBuildPath = '/home/zeachco/dev/css/build/style.min.css';
var cssToCheck = fs.readFileSync(cssBuildPath, 'utf-8');
if (cs.utils.snapshotExist(cssBuildPath)) {
cs.renderer(url, cssToCheck, function(result) {
var validshot = require(cs.utils.snapshotPath(cssBuildPath));
var diff = cs.comparator.compare(validshot, result.styles);
cs.reporter(diff)
timer();
});
} else {
log('snapshot does not exist, creating it...', 'red');
cs.renderer(url, cssToCheck, function(result) {
cs.snapshot.save(cssBuildPath, result.styles);
log('snapshot saved, you may run it again after changes');
timer();
});
}