Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #111 from TomSputz/pipe
Finished up Pipe
  • Loading branch information
eddiemoore committed Apr 2, 2019
2 parents aa5a2b0 + ad51194 commit d81c4f4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -41,6 +41,8 @@ Repo tokens are necessary to distinguish your repository from others. You can fi
export CODECOV_TOKEN=":uuid-repo-token"
# or
./node_modules/.bin/codecov --token=:token
# or
./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/codecov --pipe
```

#### [Istanbul](https://github.com/gotwarlost/istanbul)
Expand Down
18 changes: 16 additions & 2 deletions bin/codecov
Expand Up @@ -21,7 +21,21 @@ var args = argv.option([
{name: 'url', short: 'u', type: 'string', description: "Your Codecov endpoint"},
{name: 'flags', short: 'F', type: 'string', description: "Codecov Flags"},
{name: 'dump', type: 'boolean', description: "Dump collected data and do not send to Codecov"},
{name: 'yml', short: 'y', type: 'string', description: "Configuration file Used to specify the location of the .codecov.yml config file. Defaults to codecov.yml and .codecov.yml"}
{name: 'pipe', short: 'l', type: 'boolean', description: "Listen to stdin for coverage data"},
{name: 'yml', short: 'y', type: 'string', description: "Configuration file Used to specify the location of the .codecov.yml config file. Defaults to codecov.yml and .codecov.yml"},
]).run();

codecov.upload(args);
if (args.options.pipe) {
process.stdin.setEncoding('utf8');
args.options.pipe = [];

process.stdin.on('data', function(report) {
args.options.pipe.push(report);
});

process.stdin.on('end', function() {
codecov.upload(args);
});
} else {
codecov.upload(args);
}
8 changes: 6 additions & 2 deletions lib/codecov.js
Expand Up @@ -451,8 +451,12 @@ var upload = function(args, on_success, on_failure) {

var files = [],
file = null
// Append manually entered reports
if (args.options.file) {
if (args.options.pipe) {
// Append piped reports
upload += '# path=piped\n' + args.options.pipe.join('') + '\n<<<<<< EOF\n'
console.log('==> Reading report from stdin')
} else if (args.options.file) {
// Append manually entered reports
file = args.options.file
console.log('==> Targeting specific file')
try {
Expand Down
15 changes: 15 additions & 0 deletions test/index.js
Expand Up @@ -225,6 +225,21 @@ describe('Codecov', function() {
}
})

it('can read piped reports', function(done) {
var exec = require('child_process').exec
var childProcess = exec(
'cat test/example.coverage.txt | bin/codecov -l --dump --disable=gcov',
function(err, stdout) {
expect(stdout.toString()).to.contain('path=piped')
expect(stdout.toString()).to.contain(
'this file is intentionally left blank'
)
childProcess.kill()
done()
}
)
})

it('should have the correct version number', function() {
var version = require('../package.json').version
expect(codecov.version).to.eql('v' + version)
Expand Down

0 comments on commit d81c4f4

Please sign in to comment.