w3c-html-validator 1.0.1 → 1.0.2

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/README.md CHANGED
@@ -6,7 +6,7 @@ _A package for testing HTML files or URLs against the W3C validator_
6
6
  [![License:MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/center-key/w3c-html-validator/blob/main/LICENSE.txt)
7
7
  [![npm](https://img.shields.io/npm/v/w3c-html-validator.svg)](https://www.npmjs.com/package/w3c-html-validator)
8
8
  [![Vulnerabilities](https://snyk.io/test/github/center-key/w3c-html-validator/badge.svg)](https://snyk.io/test/github/center-key/w3c-html-validator)
9
- [![Build](https://github.com/center-key/w3c-html-validator/workflows/build/badge.svg)](https://github.com/center-key/w3c-html-validator/actions?query=workflow%3Abuild)
9
+ [![Build](https://github.com/center-key/w3c-html-validator/workflows/build/badge.svg)](https://github.com/center-key/w3c-html-validator/actions/workflows/run-spec-on-push.yaml)
10
10
 
11
11
  ## 1) Setup
12
12
 
package/bin/cli.js CHANGED
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env node
2
- // w3c-html-validator ~~ MIT License
3
- //
2
+ ////////////////////////
3
+ // w3c-html-validator //
4
+ // MIT License //
5
+ ////////////////////////
6
+
4
7
  // Usage in package.json:
5
8
  // "scripts": {
6
9
  // "validate": "w3c-html-validator docs/*.html flyer.html",
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v1.0.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v1.0.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  export declare type ValidatorOptions = {
4
4
  html?: string;
@@ -1,11 +1,11 @@
1
- //! w3c-html-validator v1.0.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v1.0.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  import { readFileSync } from 'fs';
4
4
  import chalk from 'chalk';
5
5
  import log from 'fancy-log';
6
6
  import request from 'superagent';
7
7
  const w3cHtmlValidator = {
8
- version: '1.0.1',
8
+ version: '1.0.2',
9
9
  validate(options) {
10
10
  const defaults = {
11
11
  checkUrl: 'https://validator.w3.org/nu/',
@@ -50,22 +50,23 @@ const w3cHtmlValidator = {
50
50
  return response;
51
51
  };
52
52
  const toValidatorResults = (response) => ({
53
- validates: json ? !response.body.messages.length : response.text.includes(success),
53
+ validates: json ? !response.body.messages.length : !!response.text?.includes(success),
54
54
  mode: mode,
55
55
  title: titleLookup[mode],
56
56
  html: inputHtml,
57
57
  filename: settings.filename || null,
58
58
  website: settings.website || null,
59
59
  output: settings.output,
60
- status: response.statusCode,
60
+ status: response.statusCode || -1,
61
61
  messages: json ? response.body.messages : null,
62
62
  display: json ? null : response.text,
63
63
  });
64
64
  const handleError = (reason) => {
65
65
  const response = reason['response'];
66
- const message = [response.status, response.res.statusMessage, response.request.url];
67
- const networkError = { type: 'network-error', message: message.join(' ') };
68
- return toValidatorResults({ ...response, ...{ body: { messages: [networkError] } } });
66
+ const getMsg = () => [response.status, response.res.statusMessage, response.request.url];
67
+ const message = response ? getMsg() : [reason['errno'], reason.message];
68
+ const networkErr = { type: 'network-error', message: message.join(' ') };
69
+ return toValidatorResults({ ...response, ...{ body: { messages: [networkErr] } } });
69
70
  };
70
71
  return w3cRequest.then(filterMessages).then(toValidatorResults).catch(handleError);
71
72
  },
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v1.0.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v1.0.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  const fancy_log_1 = __importDefault(require("fancy-log"));
21
21
  const superagent_1 = __importDefault(require("superagent"));
22
22
  const w3cHtmlValidator = {
23
- version: '1.0.1',
23
+ version: '1.0.2',
24
24
  validate(options) {
25
25
  const defaults = {
26
26
  checkUrl: 'https://validator.w3.org/nu/',
@@ -65,22 +65,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
65
65
  return response;
66
66
  };
67
67
  const toValidatorResults = (response) => ({
68
- validates: json ? !response.body.messages.length : response.text.includes(success),
68
+ validates: json ? !response.body.messages.length : !!response.text?.includes(success),
69
69
  mode: mode,
70
70
  title: titleLookup[mode],
71
71
  html: inputHtml,
72
72
  filename: settings.filename || null,
73
73
  website: settings.website || null,
74
74
  output: settings.output,
75
- status: response.statusCode,
75
+ status: response.statusCode || -1,
76
76
  messages: json ? response.body.messages : null,
77
77
  display: json ? null : response.text,
78
78
  });
79
79
  const handleError = (reason) => {
80
80
  const response = reason['response'];
81
- const message = [response.status, response.res.statusMessage, response.request.url];
82
- const networkError = { type: 'network-error', message: message.join(' ') };
83
- return toValidatorResults({ ...response, ...{ body: { messages: [networkError] } } });
81
+ const getMsg = () => [response.status, response.res.statusMessage, response.request.url];
82
+ const message = response ? getMsg() : [reason['errno'], reason.message];
83
+ const networkErr = { type: 'network-error', message: message.join(' ') };
84
+ return toValidatorResults({ ...response, ...{ body: { messages: [networkErr] } } });
84
85
  };
85
86
  return w3cRequest.then(filterMessages).then(toValidatorResults).catch(handleError);
86
87
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w3c-html-validator",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A package for testing HTML files or URLs against the W3C validator (written in TypeScript)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -83,12 +83,12 @@
83
83
  "@types/glob": "~7.2",
84
84
  "@types/node": "~17.0",
85
85
  "@types/superagent": "~4.1",
86
- "@typescript-eslint/eslint-plugin": "~5.10",
87
- "@typescript-eslint/parser": "~5.10",
86
+ "@typescript-eslint/eslint-plugin": "~5.11",
87
+ "@typescript-eslint/parser": "~5.11",
88
88
  "add-dist-header": "~0.1",
89
89
  "assert-deep-strict-equal": "~1.0",
90
90
  "cpy-cli": "~3.1",
91
- "eslint": "~8.7",
91
+ "eslint": "~8.8",
92
92
  "jshint": "~2.13",
93
93
  "merge-stream": "~2.0",
94
94
  "mocha": "~9.2",