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

Finished up Pipe #111

Merged
merged 18 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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