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

Commit d81c4f4

Browse files
authored
Merge pull request #111 from TomSputz/pipe
Finished up Pipe
2 parents aa5a2b0 + ad51194 commit d81c4f4

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Repo tokens are necessary to distinguish your repository from others. You can fi
4141
export CODECOV_TOKEN=":uuid-repo-token"
4242
# or
4343
./node_modules/.bin/codecov --token=:token
44+
# or
45+
./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/codecov --pipe
4446
```
4547

4648
#### [Istanbul](https://github.com/gotwarlost/istanbul)

bin/codecov

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@ var args = argv.option([
2121
{name: 'url', short: 'u', type: 'string', description: "Your Codecov endpoint"},
2222
{name: 'flags', short: 'F', type: 'string', description: "Codecov Flags"},
2323
{name: 'dump', type: 'boolean', description: "Dump collected data and do not send to Codecov"},
24-
{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"}
24+
{name: 'pipe', short: 'l', type: 'boolean', description: "Listen to stdin for coverage data"},
25+
{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"},
2526
]).run();
2627

27-
codecov.upload(args);
28+
if (args.options.pipe) {
29+
process.stdin.setEncoding('utf8');
30+
args.options.pipe = [];
31+
32+
process.stdin.on('data', function(report) {
33+
args.options.pipe.push(report);
34+
});
35+
36+
process.stdin.on('end', function() {
37+
codecov.upload(args);
38+
});
39+
} else {
40+
codecov.upload(args);
41+
}

lib/codecov.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,12 @@ var upload = function(args, on_success, on_failure) {
451451

452452
var files = [],
453453
file = null
454-
// Append manually entered reports
455-
if (args.options.file) {
454+
if (args.options.pipe) {
455+
// Append piped reports
456+
upload += '# path=piped\n' + args.options.pipe.join('') + '\n<<<<<< EOF\n'
457+
console.log('==> Reading report from stdin')
458+
} else if (args.options.file) {
459+
// Append manually entered reports
456460
file = args.options.file
457461
console.log('==> Targeting specific file')
458462
try {

test/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,21 @@ describe('Codecov', function() {
225225
}
226226
})
227227

228+
it('can read piped reports', function(done) {
229+
var exec = require('child_process').exec
230+
var childProcess = exec(
231+
'cat test/example.coverage.txt | bin/codecov -l --dump --disable=gcov',
232+
function(err, stdout) {
233+
expect(stdout.toString()).to.contain('path=piped')
234+
expect(stdout.toString()).to.contain(
235+
'this file is intentionally left blank'
236+
)
237+
childProcess.kill()
238+
done()
239+
}
240+
)
241+
})
242+
228243
it('should have the correct version number', function() {
229244
var version = require('../package.json').version
230245
expect(codecov.version).to.eql('v' + version)

0 commit comments

Comments
 (0)