forked from hoobdeebla/gulp-html-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (22 loc) · 790 Bytes
/
index.js
File metadata and controls
29 lines (22 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var es = require('event-stream');
var path = require('path');
var htmlv = require('html-validator');
module.exports = function(options) {
if (!options) options = {};
function modifyContents(file, cb) {
if (file.isNull()) return cb(null, file); // pass along
if (file.isStream()) return cb(new Error('htmlv: Streaming not supported')); // pass error if streaming is not supported
options.data = file.contents.toString('utf8');
htmlv(options, function (err, data) {
if (err) return cb(err);
if (options.format === 'json') {
file.contents = new Buffer(JSON.stringify(data));
} else {
file.contents = new Buffer(String(data));
}
return cb(null, file);
});
}
// Return a stream
return es.map(modifyContents);
};