-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
37 lines (32 loc) · 848 Bytes
/
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
'use strict'
const through = require('through2')
const PluginError = require('plugin-error')
const codecov = require('codecov')
const PLUGIN_NAME = 'gulp-codecov'
module.exports = opts =>
through.obj(function (file, enc, callback) {
const sendToCodecov = (path, done) => {
const options = opts || {}
options.file = path
codecov.handleInput.upload(
{ options },
() => done(null, file),
err => done(new PluginError(PLUGIN_NAME, err))
)
}
if (file.isNull()) {
this.push(file)
return callback()
}
if (file.isStream()) {
this.emit(
'error',
new PluginError(PLUGIN_NAME, 'Stream content is not supported')
)
return callback()
}
if (file.isBuffer()) {
sendToCodecov(file.path, callback)
this.push(file)
}
})