-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
47 lines (40 loc) · 974 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const argv = require('yargs').argv,
byline = require('byline'),
config = require('./config'),
fs = require('fs-extra'),
h = require('highland'),
main = require('./lib/shots').main,
urls = [],
yaml = require('js-yaml');
let fileStream, diffMap;
function readText(filepath) {
return h(byline(fs.createReadStream(filepath, 'utf8')));
}
function readYAML(filepath) {
return h((fs.readFile(filepath, 'utf8')));
}
fs.ensureDirSync(config.screenshotsDir);
fs.ensureDirSync(config.diffDir);
if (argv.f) {
if (argv.d) {
readYAML(argv.f)
.map(yaml.safeLoad)
.each(function(data){
diffMap = data;
data.forEach((val)=>{
urls.push(val.reference);
urls.push(val.tester);
});
})
.done(function(){
main(urls, diffMap);
});
} else {
readText(argv.f)
.toArray(function(urls){
main(urls);
});
}
} else {
console.error('you need to enter a file!');
}