-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (36 loc) · 1.03 KB
/
index.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict'
var through = require('through2')
var standard = require('standard')
var PluginErr = require('gulp-util').PluginError
module.exports = exports = function standardize () {
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
return cb(null, file)
}
if (file.isStream()) {
return cb(new PluginErr('gulp-standardize', 'Streams are not supported!'))
}
standard.lintText(file.contents.toString(), function (err, data) {
if (err) return cb(err)
file.standard = {
results: data.results[0],
success: !(data.errorCount + data.warningCount)
}
cb(null, file)
})
})
}
exports.reporter = function reporter (style, opts) {
if (!style || style === 'default') style = 'snazzy'
if (typeof style === 'function') return style(opts)
if (typeof style === 'string') {
try {
return require('./reporters/' + style)(opts)
} catch (e) {}
try {
return require(style)(opts)
} catch (e) {}
}
// Fall thru
return through.obj()
}