diff options
| author | Anna Henningsen <[email protected]> | 2015-02-04 01:46:30 +0100 |
|---|---|---|
| committer | Anna Henningsen <[email protected]> | 2015-12-10 22:14:39 +0100 |
| commit | 7d9d9a4514c12c80b4c9475d57d674bf775c9149 (patch) | |
| tree | b28f1acc9da37a3fa619012906c6c3250aea0654 /lib/sendToCoveralls.js | |
| parent | 3794d16027767014919116bd85a32e3d3de7efa8 (diff) | |
| download | node-coveralls-7d9d9a4514c12c80b4c9475d57d674bf775c9149.tar.xz node-coveralls-7d9d9a4514c12c80b4c9475d57d674bf775c9149.zip | |
Add command line option to write output to stdout
Adds the command line option pair -w/--write.
These options indicate that the output should be written to standard output,
rather than being posted to coveralls.io, which may be useful for debugging,
mixed-language codebases (e.g. node addons with C++ code) etc.
Diffstat (limited to 'lib/sendToCoveralls.js')
| -rw-r--r-- | lib/sendToCoveralls.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/sendToCoveralls.js b/lib/sendToCoveralls.js index 38b37f7..f574997 100644 --- a/lib/sendToCoveralls.js +++ b/lib/sendToCoveralls.js @@ -8,9 +8,21 @@ var sendToCoveralls = function(obj, cb){ var str = JSON.stringify(obj); var url = urlBase + '/api/v1/jobs'; - request.post({url : url, form : { json : str}}, function(err, response, body){ - cb(err, response, body); - }); + + if (hasWriteToStdoutOption()) { + process.stdout.write(str); + cb(null, { statusCode: 200 }, ''); + } else { + request.post({url : url, form : { json : str}}, function(err, response, body){ + cb(err, response, body); + }); + } }; +function hasWriteToStdoutOption(){ + // look into command line arguments starting from index 2 + return process.argv.slice(2).filter(RegExp.prototype.test.bind(/^(-w|--write)$/)).length > 0; +} + + module.exports = sendToCoveralls; |
