-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.js
38 lines (33 loc) · 959 Bytes
/
cli.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
#!/usr/bin/env node
'use strict';
var program = require('commander');
var W3CValidator = require('./lib/W3CValidator.js');
var chalk = require('chalk');
var pkg = require('./package.json');
program.version(pkg.version)
.usage('[options] <url>')
.option('-l, --log', 'log errors in a text file')
.option('-m, --max <n>', 'max URLs to crawl')
.option('-q, --query', 'consider query string')
.option('-v, --verbose', 'show error details')
.parse(process.argv);
if (!program.args[0]) {
program.help();
process.exit();
}
require('find-java-home')(function (err, java_home) {
var validator;
if (!err) {
validator = new W3CValidator({
url: program.args[0],
query: program.query,
verbose: program.verbose,
log: program.log,
max: program.max,
}, java_home);
validator.start();
} else {
console.error(chalk.red.bold('Error: Java is required to use w3c-validator!'));
process.exit(1);
}
});