Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,23 @@ module.exports = gulpHtmlValidate;
function gulpHtmlValidate() {
const htmlvalidate = htmlValidateCli.getValidator();

return through.obj((file, encoding, callback) => {
if (file.isNull()) {
callback(null, file);
return;
}
return through.obj(async (file, encoding, callback) => {
try {
if (file.isNull() || file.isStream()) {
throw new PluginError(pluginName, 'File is null or Streaming not supported');
}

if (file.isStream()) {
callback(new PluginError(pluginName, 'Streaming not supported'));
const result = await htmlvalidate.validateString(file.contents.toString(), file.path);
file.htmlValidateResult = result;
} catch (err) {
callback(err);
return;
}

const result = htmlvalidate.validateString(
file.contents.toString(),
file.path
);
file.htmlValidateResult = result;

callback(null, file);
});
}


/**
* Print a report where all errors/warnings are listed.
*
Expand Down