w3c-html-validator 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +3 -2
- package/dist/w3c-html-validator.d.ts +1 -1
- package/dist/w3c-html-validator.js +8 -6
- package/package.json +5 -4
package/bin/cli.js
CHANGED
|
@@ -26,6 +26,7 @@ import { cliArgvUtil } from 'cli-argv-util';
|
|
|
26
26
|
import { globSync } from 'glob';
|
|
27
27
|
import { w3cHtmlValidator } from '../dist/w3c-html-validator.js';
|
|
28
28
|
import fs from 'fs';
|
|
29
|
+
import slash from 'slash';
|
|
29
30
|
|
|
30
31
|
// Parameters and flags
|
|
31
32
|
const validFlags = ['continue', 'delay', 'exclude', 'ignore', 'ignore-config', 'note', 'quiet', 'trim'];
|
|
@@ -39,9 +40,9 @@ const trim = Number(cli.flagMap.trim) || null;
|
|
|
39
40
|
// Validator
|
|
40
41
|
const globOptions = { ignore: '**/node_modules/**/*' };
|
|
41
42
|
const keep = (filename) => !filename.includes('node_modules/');
|
|
42
|
-
const readFolder = (folder) => globSync(folder + '**/*.html', globOptions);
|
|
43
|
+
const readFolder = (folder) => globSync(slash(folder + '**/*.html'), globOptions);
|
|
44
|
+
const getAllPaths = () => files.map(file => globSync(slash(file), globOptions)).flat();
|
|
43
45
|
const expandFolder = (file) => fs.lstatSync(file).isDirectory() ? readFolder(file + '/') : file;
|
|
44
|
-
const getAllPaths = () => files.map(file => globSync(file, globOptions)).flat();
|
|
45
46
|
const getFilenames = () => getAllPaths().map(expandFolder).flat().filter(keep).sort();
|
|
46
47
|
const list = files.length ? getFilenames() : readFolder('');
|
|
47
48
|
const excludes = cli.flagMap.exclude?.split(',') ?? [];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
//! w3c-html-validator v1.6.
|
|
1
|
+
//! w3c-html-validator v1.6.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
|
|
2
2
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import log from 'fancy-log';
|
|
6
6
|
import request from 'superagent';
|
|
7
|
+
import slash from 'slash';
|
|
7
8
|
const w3cHtmlValidator = {
|
|
8
|
-
version: '1.6.
|
|
9
|
+
version: '1.6.1',
|
|
9
10
|
validate(options) {
|
|
10
11
|
const defaults = {
|
|
11
12
|
checkUrl: 'https://validator.w3.org/nu/',
|
|
@@ -20,9 +21,10 @@ const w3cHtmlValidator = {
|
|
|
20
21
|
throw Error('[w3c-html-validator] Invalid ignoreLevel option: ' + settings.ignoreLevel);
|
|
21
22
|
if (settings.output !== 'json' && settings.output !== 'html')
|
|
22
23
|
throw Error('[w3c-html-validator] Option "output" must be "json" or "html".');
|
|
23
|
-
const
|
|
24
|
+
const filename = settings.filename ? slash(settings.filename) : null;
|
|
25
|
+
const mode = settings.html ? 'html' : filename ? 'filename' : 'website';
|
|
24
26
|
const readFile = (filename) => fs.readFileSync(filename, 'utf-8').replace(/\r/g, '');
|
|
25
|
-
const inputHtml = settings.html ?? (
|
|
27
|
+
const inputHtml = settings.html ?? (filename ? readFile(filename) : null);
|
|
26
28
|
const makePostRequest = () => request.post(settings.checkUrl)
|
|
27
29
|
.set('Content-Type', 'text/html; encoding=utf-8')
|
|
28
30
|
.send(inputHtml);
|
|
@@ -35,7 +37,7 @@ const w3cHtmlValidator = {
|
|
|
35
37
|
const success = '<p class="success">';
|
|
36
38
|
const titleLookup = {
|
|
37
39
|
html: 'HTML String (characters: ' + inputHtml?.length + ')',
|
|
38
|
-
filename:
|
|
40
|
+
filename: filename,
|
|
39
41
|
website: settings.website,
|
|
40
42
|
};
|
|
41
43
|
const filterMessages = (response) => {
|
|
@@ -52,7 +54,7 @@ const w3cHtmlValidator = {
|
|
|
52
54
|
mode: mode,
|
|
53
55
|
title: titleLookup[mode],
|
|
54
56
|
html: inputHtml,
|
|
55
|
-
filename:
|
|
57
|
+
filename: filename,
|
|
56
58
|
website: settings.website || null,
|
|
57
59
|
output: settings.output,
|
|
58
60
|
status: response.statusCode || -1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w3c-html-validator",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Check the markup validity of HTML files using the W3C validator",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -86,15 +86,16 @@
|
|
|
86
86
|
"cli-argv-util": "~1.2",
|
|
87
87
|
"fancy-log": "~2.0",
|
|
88
88
|
"glob": "~10.3",
|
|
89
|
+
"slash": "~5.1",
|
|
89
90
|
"superagent": "~8.1"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@types/fancy-log": "~2.0",
|
|
93
94
|
"@types/glob": "~8.1",
|
|
94
|
-
"@types/node": "~20.
|
|
95
|
+
"@types/node": "~20.9",
|
|
95
96
|
"@types/superagent": "~4.1",
|
|
96
|
-
"@typescript-eslint/eslint-plugin": "~6.
|
|
97
|
-
"@typescript-eslint/parser": "~6.
|
|
97
|
+
"@typescript-eslint/eslint-plugin": "~6.10",
|
|
98
|
+
"@typescript-eslint/parser": "~6.10",
|
|
98
99
|
"add-dist-header": "~1.3",
|
|
99
100
|
"assert-deep-strict-equal": "~1.1",
|
|
100
101
|
"copy-file-util": "~1.1",
|