-
Notifications
You must be signed in to change notification settings - Fork 0
/
website-diff.js
executable file
·89 lines (70 loc) · 2.02 KB
/
website-diff.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env node
'use strict';
const meow = require('meow');
async function main() {
const cli = meow(
`
Usage
$ website-diff COMMAND [OPTIONS]
Commands:
init Create config file
crawl Crawl a site
generate Generate backstop config
reference Create backstop reference data
test Run backstop test
run Run all command in sequence
Options:
--url Url to check
--reference-url Reference url to compare
--config Config file
`,
{
flags: {
config: {
type: 'string',
alias: 'c',
},
url: {
type: 'string'
},
referenceUrl: {
type: 'string'
}
}
}
);
if (cli.input.length == 0) {
cli.showHelp();
process.exit(0);
}
let start = +new Date();
console.log('Started at:', new Date().toLocaleTimeString())
switch (cli.input[0]) {
case 'crawl':
require('./bin/crawl')();
break;
case 'generate':
await require('./bin/generate-config')();
break;
case 'reference':
await require('./bin/reference')();
break;
case 'test':
await require('./bin/test')();
break;
case 'run':
await require('./bin/generate-config')();
await require('./bin/reference')();
await require('./bin/test')();
break;
case 'init':
await require('./bin/init')();
break;
default:
cli.showHelp();
break;
}
console.log('Finished at:', new Date().toLocaleTimeString())
console.log('Total time:', new Date(+new Date() - start).toISOString().substr(11, 8))
}
main();