Skip to content

Commit a018796

Browse files
committed
first commit
1 parent f3fbf08 commit a018796

File tree

4 files changed

+1626
-0
lines changed

4 files changed

+1626
-0
lines changed

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Файлы и папки операционной системы
2+
.DS_Store
3+
Thumbs.db
4+
5+
# Файлы редактора
6+
.idea
7+
*.sublime*
8+
.vscode
9+
10+
# Вспомогательные файлы
11+
*.log*
12+
node_modules/
13+
bower_components/
14+
15+
# Папка с собранными файлами проекта
16+
build/
17+
src/*.html
18+
src/images/sprite
19+
src/images/sprite-svg
20+
src/images/symbols-svg
21+
src/js/script.js
22+
src/css/

index.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import through from 'through2';
2+
import { HtmlValidate } from 'html-validate';
3+
import { text as textFormat } from 'html-validate/build/formatters/text';
4+
import c from "ansi-colors";
5+
import log from "fancy-log";
6+
import PluginError from "plugin-error";
7+
8+
const PLUGIN_NAME = 'gulp-html-validate';
9+
10+
function validate(file, encoding, callback) {
11+
try {
12+
const htmlvalidate = new HtmlValidate();
13+
const report = htmlvalidate.validateFile(file.path);
14+
15+
if (!report.valid) {
16+
log(c.red(`File is not valid => ${report.results[0].filePath}`));
17+
log(c.green(`File - ${textFormat(report.results)}`));
18+
}
19+
callback(null, file);
20+
} catch (error) {
21+
const err = new PluginError({
22+
plugin: PLUGIN_NAME,
23+
message: error
24+
});
25+
26+
log.error(err);
27+
}
28+
}
29+
30+
module.exports = () => through.obj(validate);

0 commit comments

Comments
 (0)