Skip to content

Commit 964c8d3

Browse files
author
dutchenkoOleg
committed
1.1.0
1 parent d0de119 commit 964c8d3

File tree

6 files changed

+49
-17
lines changed

6 files changed

+49
-17
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
88
---
99

10+
## [1.1.0] - 2017.07.11
11+
12+
#### Added
13+
14+
- CLI / Node.js options:
15+
- [--filterfile <filename>](./README.md#--filterfile-filename)
16+
- [--filterpattern <pattern>](./README.md#--filterpattern-pattern)
17+
18+
#### Changed
19+
20+
- Readme description
21+
1022
## [1.0.5] - 2017.07.10
1123

1224
- add more `README.md` description

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ npm i -g node-w3c-validator
2121
Usage
2222

2323
```shell
24-
node-w3c-validator -i ./dist/ -f html -o ./reports/result.html -s
24+
node-w3c-validator -i ./dist/*.html -f html -o ./reports/result.html -s
2525
```
2626

2727
### Options
@@ -52,6 +52,18 @@ Specifies the output format for reporting the results
5252
default: `unset`
5353
possible values: `gnu | xml | json | text | html`
5454

55+
#### `--filterfile <filename>`
56+
57+
Specifies a filename. Each line of the file contains either a regular expression or starts with "#" to indicate the line is a comment. Any error message or warning message that matches a regular expression in the file is filtered out (dropped/suppressed)
58+
59+
default: `unset`, _checker does no message filtering_
60+
61+
#### `--filterpattern <pattern>`
62+
63+
Specifies a regular-expression pattern. Any error message or warning message that matches the pattern is filtered out (dropped/suppressed)
64+
65+
default: `unset`, _checker does no message filtering_
66+
5567
#### `-s, --skip-non-html`
5668

5769
Skip documents that don’t have `*.html`, `*.htm`, `*.xhtml`, or `*.xht` extensions.
@@ -155,19 +167,19 @@ Name | Data type | Argument | Description
155167
const nodeW3CValidator = require('node-w3c-validator');
156168

157169
// paths
158-
const validatePath = './dist/'; // or directly to the file - './dist/index.html'
170+
const validatePath = './dist/*.html'; // or directly to the file - './dist/index.html'
159171
const resultOutput = './reports/result.html';
160172

161173
// validate
162174
nodeW3CValidator(validatePath, {
163-
format: 'html',
164-
skipNonHtml: true,
165-
verbose: true
175+
format: 'html',
176+
skipNonHtml: true,
177+
verbose: true
166178
}, function (err, output) {
167-
if (err === null) {
168-
return;
169-
}
170-
nodeW3CValidator.writeFile(resultOutput, output);
179+
if (err === null) {
180+
return;
181+
}
182+
nodeW3CValidator.writeFile(resultOutput, output);
171183
});
172184
```
173185

bin/cmd.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ program
2121
.option('-a, --asciiquotes', 'Specifies whether ASCII quotation marks are substituted for Unicode smart quotation marks in messages.')
2222
.option('-e, --errors-only', 'Specifies that only error-level messages and non-document-error messages are reported (so that warnings and info messages are not reported)')
2323
// .option('-q, --exit-zero-always', 'Makes the checker exit zero even if errors are reported for any documents')
24-
// .option('--filterfile [filename]', 'Specifies a filename. Each line of the file contains either a regular expression or starts with "#" to indicate the line is a comment. Any error message or warning message that matches a regular expression in the file is filtered out (dropped/suppressed)')
25-
// .option('--filterpattern [pattern]', 'Specifies a regular-expression pattern. Any error message or warning message that matches the pattern is filtered out (dropped/suppressed)')
24+
.option('--filterfile [filename]', 'Specifies a filename. Each line of the file contains either a regular expression or starts with "#" to indicate the line is a comment. Any error message or warning message that matches a regular expression in the file is filtered out (dropped/suppressed)')
25+
.option('--filterpattern [pattern]', 'Specifies a regular-expression pattern. Any error message or warning message that matches the pattern is filtered out (dropped/suppressed)')
2626
.option('-f, --format [gnu|xml|json|text|html]', 'Specifies the output format for reporting the results')
2727
.option('-s, --skip-non-html', 'Skip documents that don’t have *.html, *.htm, *.xhtml, or *.xht extensions.')
2828
.option('-H, --html', 'Forces any *.xhtml or *.xht documents to be parsed using the HTML parser')

lib/validator.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ function getArgvFromObject (options) {
118118
argv.push('--no-langdetect');
119119
}
120120

121+
if (options.filterfile) {
122+
argv.push(`--filterfile ${options.filterfile}`);
123+
}
124+
125+
if (options.filterpattern) {
126+
argv.push(`--filterpattern ${options.filterpattern}`);
127+
}
128+
121129
booleanArgs.forEach(key => {
122130
if (options[key]) {
123131
argv.push(`--${camel2dash(key)}`);
@@ -142,7 +150,7 @@ function nodeW3CValidator (validationPath, userOptions, done) {
142150
let options = getOptions(userOptions);
143151
let execPath = [vnuCmd].concat(getArgvFromObject(options), validationPath);
144152

145-
// console.log(execPath.join(' '));
153+
console.log(execPath.join(' '));
146154
exec(execPath.join(' '), function (err, stdout, stderr) {
147155
let output = stdout;
148156

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-w3c-validator",
3-
"version": "1.0.5",
3+
"version": "1.1.0",
44
"description": "Wrapper for The Nu Html Checker (v.Nu)",
55
"main": "./lib/validator.js",
66
"scripts": {

tests/demo.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const nodeW3CValidator = require('../lib/validator');
1616
// Private
1717
// ----------------------------------------
1818

19-
const testFilePath = path.join(__dirname, '../tmp/');
19+
const testFilePath = path.join(__dirname, '../tmp/*.html');
2020
const destFolder = path.join(__dirname, '../results/vnu.html');
2121

2222
// ----------------------------------------
@@ -25,13 +25,13 @@ const destFolder = path.join(__dirname, '../results/vnu.html');
2525

2626
nodeW3CValidator(testFilePath, {
2727
format: 'html',
28-
skipNonHtml: true,
29-
verbose: true,
30-
outputAsHtml: true
28+
skipNonHtml: true
3129
}, function (err, output) {
3230
if (err === null) {
3331
return console.log('ok');
3432
}
33+
console.log('Resulting report will be written in path:');
34+
console.log(destFolder);
3535
nodeW3CValidator.writeFile(destFolder, output);
3636
});
3737

0 commit comments

Comments
 (0)