gulp-codecov
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -1,7 +0,4 @@ | ||
var gulp = require('gulp') | ||
var codecov = require('./index.js') | ||
const gulp = require('gulp') | ||
const codecov = require('./index.js') | ||
gulp.task('codecov', function () { | ||
return gulp.src('./coverage/lcov.info') | ||
.pipe(codecov()) | ||
}) | ||
gulp.task('codecov', () => gulp.src('./coverage/lcov.info').pipe(codecov())) |
34
index.js
'use strict' | ||
var through = require('through2') | ||
var gutil = require('gulp-util') | ||
var codecov = require('codecov') | ||
const through = require('through2') | ||
const gutil = require('gulp-util') | ||
const codecov = require('codecov') | ||
var PLUGIN_NAME = 'gulp-codecov' | ||
const PLUGIN_NAME = 'gulp-codecov' | ||
module.exports = function (opts) { | ||
return through.obj(function (file, enc, callback) { | ||
function sendToCodecov (path, done) { | ||
var options = opts || {} | ||
module.exports = opts => | ||
through.obj(function(file, enc, callback) { | ||
const sendToCodecov = (path, done) => { | ||
const options = opts || {} | ||
options.file = path | ||
codecov.handleInput.upload({ | ||
options: options | ||
}, function () { | ||
return done(null, file) | ||
}, function (err) { | ||
return done(new gutil.PluginError(PLUGIN_NAME, err)) | ||
}) | ||
codecov.handleInput.upload( | ||
{ options }, | ||
() => done(null, file), | ||
err => done(new gutil.PluginError(PLUGIN_NAME, err)) | ||
) | ||
} | ||
@@ -28,3 +26,6 @@ | ||
if (file.isStream()) { | ||
this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Stream content is not supported')) | ||
this.emit( | ||
'error', | ||
new gutil.PluginError(PLUGIN_NAME, 'Stream content is not supported') | ||
) | ||
return callback() | ||
@@ -38,2 +39,1 @@ } | ||
}) | ||
} |
{ | ||
"name": "gulp-codecov", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Gulp plugin to submit code coverage to Codecov", | ||
@@ -26,7 +26,8 @@ "keywords": [ | ||
"scripts": { | ||
"test": "standard && istanbul cover ./node_modules/mocha/bin/_mocha --report lcov -- -R spec", | ||
"precommit": "lint-staged", | ||
"test": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcov -- -R spec", | ||
"codecov": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && gulp codecov && rm -rf ./coverage" | ||
}, | ||
"dependencies": { | ||
"codecov": "^2.1.0", | ||
"codecov": "^3.0.0", | ||
"gulp-util": "^3.0.8", | ||
@@ -37,10 +38,12 @@ "path": "^0.12.7", | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"chai": "^4.0.2", | ||
"event-stream": "^3.3.4", | ||
"gulp": "^3.9.1", | ||
"husky": "0.14.3", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.3.0", | ||
"lint-staged": "7.2.0", | ||
"mocha": "^5.2.0", | ||
"mocha-lcov-reporter": "^1.3.0", | ||
"sinon": "^2.2.0", | ||
"standard": "^10.0.2" | ||
"prettier": "1.13.5", | ||
"sinon": "6.0.0" | ||
}, | ||
@@ -51,3 +54,13 @@ "engines": { | ||
}, | ||
"license": "MIT" | ||
"license": "MIT", | ||
"lint-staged": { | ||
"**/*.js": [ | ||
"prettier --write", | ||
"git add" | ||
], | ||
"*.js": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
} | ||
} |
@@ -1,5 +0,7 @@ | ||
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency Status][depstat-image]][depstat-url] [![Dev Dependency Status][devdepstat-image]][devdepstat-url] [![npm Downloads][downloads-image]][npm-url] | ||
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency Status][depstat-image]][depstat-url] [![Dev Dependency Status][devdepstat-image]][devdepstat-url] [![npm Downloads][downloads-image]][npm-url] [![code style: prettier][prettier-image]][prettier-url] | ||
# gulp-codecov | ||
[](https://greenkeeper.io/) | ||
[Gulp](https://github.com/wearefractal/gulp) plugin to submit code coverage to [Codecov.io](http://codecov.io). | ||
@@ -18,6 +20,5 @@ | ||
```javascript | ||
var codecov = require('gulp-codecov'); | ||
var codecov = require('gulp-codecov') | ||
gulp.src('./coverage/lcov.info') | ||
.pipe(codecov()); | ||
gulp.src('./coverage/lcov.info').pipe(codecov()) | ||
``` | ||
@@ -31,15 +32,12 @@ | ||
[npm-image]: https://img.shields.io/npm/v/gulp-codecov.svg?style=flat-square | ||
[travis-url]: http://travis-ci.org/eddiemoore/gulp-codecov | ||
[travis-image]: https://img.shields.io/travis/eddiemoore/gulp-codecov/master.svg?style=flat-square | ||
[codecov-url]: https://codecov.io/github/eddiemoore/gulp-codecov | ||
[codecov-image]: https://img.shields.io/codecov/c/github/eddiemoore/gulp-codecov/master.svg?style=flat-square | ||
[depstat-url]: https://david-dm.org/eddiemoore/gulp-codecov | ||
[depstat-image]: https://img.shields.io/david/eddiemoore/gulp-codecov/master.svg?style=flat-square | ||
[devdepstat-url]: https://david-dm.org/eddiemoore/gulp-codecov#info=devDependencies | ||
[devdepstat-image]: https://img.shields.io/david/dev/eddiemoore/gulp-codecov/master.svg?style=flat-square | ||
[downloads-image]: https://img.shields.io/npm/dt/gulp-codecov.svg?maxAge=2592000&style=flat-square | ||
[prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square | ||
[prettier-url]: https://github.com/prettier/prettier |
107
test/main.js
/* global describe, it, beforeEach, afterEach */ | ||
'use strict' | ||
var expect = require('chai').expect | ||
var fs = require('fs') | ||
var es = require('event-stream') | ||
var gutil = require('gulp-util') | ||
var sinon = require('sinon') | ||
var codecov = require('codecov') | ||
var gulpCodecov = require('../') | ||
const expect = require('chai').expect | ||
const fs = require('fs') | ||
const es = require('event-stream') | ||
const gutil = require('gulp-util') | ||
const sinon = require('sinon') | ||
const codecov = require('codecov') | ||
const gulpCodecov = require('../') | ||
describe('gulp-codecov', function () { | ||
describe('gulp-codecov', () => { | ||
process.env.TRAVIS = 'true' | ||
@@ -20,13 +20,13 @@ process.env.TRAVIS_JOB_ID = '1234' | ||
describe('success', function () { | ||
beforeEach(function () { | ||
describe('success', () => { | ||
beforeEach(() => { | ||
sinon.stub(codecov.handleInput, 'upload').callsArgWith(1, 'success') | ||
}) | ||
afterEach(function () { | ||
afterEach(() => { | ||
codecov.handleInput.upload.restore && codecov.handleInput.upload.restore() | ||
}) | ||
it('should pass the file through via buffer', function (done) { | ||
var srcFile = new gutil.File({ | ||
it('should pass the file through via buffer', done => { | ||
const srcFile = new gutil.File({ | ||
base: 'test/fixtures', | ||
@@ -38,5 +38,5 @@ cwd: 'test/', | ||
var stream = gulpCodecov() | ||
const stream = gulpCodecov() | ||
stream.once('error', function (err) { | ||
stream.once('error', err => { | ||
expect(err).to.exist // eslint-disable-line | ||
@@ -46,6 +46,8 @@ done(err) | ||
stream.once('data', function (newFile) { | ||
stream.once('data', newFile => { | ||
expect(newFile).to.exist // eslint-disable-line | ||
expect(newFile.contents).to.exist // eslint-disable-line | ||
expect(String(newFile.contents)).to.equal(fs.readFileSync('test/expected/lcov.info', 'utf8')) | ||
expect(String(newFile.contents)).to.equal( | ||
fs.readFileSync('test/expected/lcov.info', 'utf8') | ||
) | ||
done() | ||
@@ -58,4 +60,4 @@ }) | ||
it('should send the file contents to Codecov', function (done) { | ||
var srcFile = new gutil.File({ | ||
it('should send the file contents to Codecov', done => { | ||
const srcFile = new gutil.File({ | ||
path: 'test/fixtures/lcov.info', | ||
@@ -67,13 +69,18 @@ cwd: 'test/', | ||
var stream = gulpCodecov() | ||
const stream = gulpCodecov() | ||
stream.write(srcFile) | ||
stream.end() | ||
stream.once('data', function () { | ||
stream.once('data', () => { | ||
sinon.assert.calledOnce(codecov.handleInput.upload) | ||
sinon.assert.calledWith(codecov.handleInput.upload, { | ||
options: { | ||
file: 'test/fixtures/lcov.info' | ||
} | ||
}, sinon.match.func, sinon.match.func) | ||
sinon.assert.calledWith( | ||
codecov.handleInput.upload, | ||
{ | ||
options: { | ||
file: 'test/fixtures/lcov.info' | ||
} | ||
}, | ||
sinon.match.func, | ||
sinon.match.func | ||
) | ||
done() | ||
@@ -84,4 +91,4 @@ }) | ||
describe('when Codecov responds with an error', function () { | ||
beforeEach(function () { | ||
describe('when Codecov responds with an error', () => { | ||
beforeEach(() => { | ||
sinon.stub(codecov.handleInput, 'upload').callsArgWith(2, { | ||
@@ -94,8 +101,8 @@ stack: 'err', | ||
afterEach(function () { | ||
afterEach(() => { | ||
codecov.handleInput.upload.restore && codecov.handleInput.upload.restore() | ||
}) | ||
it('should emit an error', function (done) { | ||
var srcFile = new gutil.File({ | ||
it('should emit an error', done => { | ||
const srcFile = new gutil.File({ | ||
path: 'test/fixtures/lcov.info', | ||
@@ -107,5 +114,5 @@ cwd: 'test/', | ||
var stream = gulpCodecov() | ||
const stream = gulpCodecov() | ||
stream.once('error', function (error) { | ||
stream.once('error', error => { | ||
expect(error).to.exist // eslint-disable-line | ||
@@ -120,17 +127,17 @@ done() | ||
describe('nulls', function () { | ||
beforeEach(function () { | ||
describe('nulls', () => { | ||
beforeEach(() => { | ||
sinon.stub(codecov.handleInput, 'upload') | ||
}) | ||
afterEach(function () { | ||
afterEach(() => { | ||
codecov.handleInput.upload.restore && codecov.handleInput.upload.restore() | ||
}) | ||
it('should pass the file through when null', function (done) { | ||
var nullFile = new gutil.File() | ||
it('should pass the file through when null', done => { | ||
const nullFile = new gutil.File() | ||
var stream = gulpCodecov() | ||
const stream = gulpCodecov() | ||
stream.once('data', function (newFile) { | ||
stream.once('data', newFile => { | ||
expect(newFile).to.exist // eslint-disable-line | ||
@@ -146,5 +153,5 @@ sinon.assert.notCalled(codecov.handleInput.upload) | ||
describe('streams', function () { | ||
it('should error on stream', function (done) { | ||
var srcFile = new gutil.File({ | ||
describe('streams', () => { | ||
it('should error on stream', done => { | ||
const srcFile = new gutil.File({ | ||
path: 'test/fixtures/lcov.info', | ||
@@ -156,5 +163,5 @@ cwd: 'test/', | ||
var stream = gulpCodecov() | ||
const stream = gulpCodecov() | ||
stream.on('error', function (err) { | ||
stream.on('error', err => { | ||
expect(err).to.exist // eslint-disable-line | ||
@@ -164,6 +171,8 @@ done() | ||
stream.on('data', function (newFile) { | ||
newFile.contents.pipe(es.wait(function (err, data) { | ||
done(err) | ||
})) | ||
stream.on('data', newFile => { | ||
newFile.contents.pipe( | ||
es.wait((err, data) => { | ||
done(err) | ||
}) | ||
) | ||
}) | ||
@@ -170,0 +179,0 @@ |
Sorry, the diff of this file is not supported yet
21280
179
10
42
+ Added@tootallnate/once@1.1.2(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcodecov@3.8.3(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedfast-url-parser@1.1.3(transitive)
+ Addedhttp-proxy-agent@4.0.1(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedignore-walk@3.0.4(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstream-events@1.0.5(transitive)
+ Addedstubs@3.0.0(transitive)
+ Addedteeny-request@7.1.1(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedurlgrey@1.0.0(transitive)
+ Addeduuid@8.3.2(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@0.2.01.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.6.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedboom@2.10.1(transitive)
- Removedcaseless@0.11.0(transitive)
- Removedcodecov@2.3.1(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcryptiles@2.0.5(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.1.4(transitive)
- Removedgenerate-function@2.3.1(transitive)
- Removedgenerate-object-property@1.2.0(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-validator@2.0.6(transitive)
- Removedhawk@3.1.3(transitive)
- Removedhoek@2.16.3(transitive)
- Removedhttp-signature@1.1.1(transitive)
- Removedis-my-ip-valid@1.0.1(transitive)
- Removedis-my-json-valid@2.20.6(transitive)
- Removedis-property@1.0.2(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonpointer@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.8.2(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedqs@6.3.3(transitive)
- Removedrequest@2.77.0(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsntp@1.0.9(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedtough-cookie@2.3.4(transitive)
- Removedtunnel-agent@0.4.3(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedurlgrey@0.4.4(transitive)
- Removedverror@1.10.0(transitive)
Updatedcodecov@^3.0.0