Skip to content

Commit 25a12e7

Browse files
committed
added verbose option
1 parent e27f0a1 commit 25a12e7

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ $ w3c-validator --help
3131
-V, --version output the version number
3232
-q, --query consider query string
3333
-n, --nofollow validate single URL
34+
-v, --verbose show error details
3435
```
3536

3637
**Important**: Executing the w3c-validator with sites using HTML `base`-tag along with links *without* leading slashes will probably not work.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "w3c-validator",
3-
"version": "2.1.1",
3+
"version": "2.2.0",
44
"description": "Crawls a given site and checks for W3C validity.",
55
"homepage": "https://github.com/lgraubner/node-w3c-validator",
66
"author": "Lars Graubner <mail@larsgraubner.de>",

w3c-validator.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ program.version(pkg.version)
1515
.usage("[options] <url>")
1616
.option("-q, --query", "consider query string")
1717
.option("-n, --nofollow", "validate single URL")
18+
.option("-v, --verbose", "show error details")
1819
.parse(process.argv);
1920

2021
if (!program.args[0]) {
@@ -87,16 +88,22 @@ require("find-java-home")(function(err, java_home) {
8788

8889
var vnuPath = path.join(__dirname, "vnu").replace(/\s/g, "\\ ");
8990
var child = exec("java -jar " + vnuPath + "/vnu.jar --format json " + url, { env: { JAVA_HOME: java_home }}, function(error, stdout, stderr) {
90-
var result = JSON.parse(stderr);
91+
var errors = JSON.parse(stderr);
9192

9293
spinner.stop(true);
9394

94-
if (_.isEmpty(result.messages)) {
95+
if (_.isEmpty(errors.messages)) {
9596
valid++;
9697
console.log(chalk.bold.green("✓"), chalk.gray(url));
9798
} else {
9899
invalid++;
99100
console.log(chalk.red.bold("×", url));
101+
102+
if (program.verbose) {
103+
_.forEach(errors.messages, function(m) {
104+
console.log(" Line " + m.lastLine + ": " + m.message);
105+
});
106+
}
100107
}
101108

102109
if (!_.isEmpty(chunk)) {

0 commit comments

Comments
 (0)