-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcssCheck.js
More file actions
executable file
·50 lines (48 loc) · 1.38 KB
/
cssCheck.js
File metadata and controls
executable file
·50 lines (48 loc) · 1.38 KB
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
/**
* PhantomJS-based CSS metrics collector
*
* Usage:
* phantomjs --web-security=false ./cssCheck.js
* --url=<page to check>
* [--format=json|html]
*
* @version 0.0.1
*/
// parse script arguments
var args = require('system').args,
exporter = require('./lib/exporter'),
params = require('./lib/args').parse(args),
cssCheck = require('./core/cssCheck.js');
if(params.url===undefined){
console.warn("USAGE: phantomjs --web-security=false cssCheck.js --url=<http://your-site.com/index.html> --format=<JSON|HTML|SVG>");
phantom.exit();
}
if(params.format===undefined){
params.format="html";
}
try {
cssCheck.run(params, function(data, formatted){
switch(params.format.toLowerCase()){
case 'svg':
exporter.exportMarkup(formatted, '#container', function(data){
console.log(data);
phantom.exit();
});
break;
case 'json':
console.log(data);
phantom.exit();
break;
default:
exporter.exportMarkup(formatted, 'html', function(data){
console.log(data);
phantom.exit();
});
break;
}
});
}
catch(ex) {
console.log('cssCheck v' + cssCheck.version + ' failed with an error:');
phantom.exit(1);
}