diff options
| author | cainus <[email protected]> | 2013-05-29 15:07:50 -0700 |
|---|---|---|
| committer | cainus <[email protected]> | 2013-05-29 15:07:50 -0700 |
| commit | 4c0bde3ee9088d163f3956e8c3d85dfcdab9b5a0 (patch) | |
| tree | 5a6d7ab2c257570362850f69182405c09e380f44 /bin | |
| parent | 7c4bd3dab75883fb3f987c2ab3ea395ff77d9047 (diff) | |
| download | node-coveralls-4c0bde3ee9088d163f3956e8c3d85dfcdab9b5a0.tar.xz node-coveralls-4c0bde3ee9088d163f3956e8c3d85dfcdab9b5a0.zip | |
refactored for better testability.
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/coveralls.js | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/bin/coveralls.js b/bin/coveralls.js index 38e8071..698f177 100755 --- a/bin/coveralls.js +++ b/bin/coveralls.js @@ -1,10 +1,5 @@ #!/usr/bin/env node -var fs = require('fs'); -var path = require('path'); -var YAML = require('libyaml'); -var sendToCoveralls = require('../lib/sendToCoveralls'); -var convertLcovToCoveralls = require('../lib/convertLcovToCoveralls'); -var repo_token; +var handleInput = require('../lib/handleInput'); process.stdin.resume(); process.stdin.setEncoding('utf8'); @@ -16,40 +11,6 @@ process.stdin.on('data', function(chunk) { }); process.stdin.on('end', function() { - inputToCoveralls(input); + handleInput(input); }); -var inputToCoveralls = function(input){ - console.log(input); - var libDir = process.argv[2] || ''; - - if (process.env.COVERALLS_REPO_TOKEN) { - repo_token = process.env.COVERALLS_REPO_TOKEN; - } else { - var yml = path.join(process.cwd(), '.coveralls.yml'); - try { - if (fs.statSync(yml).isFile()) { - repo_token = YAML.readFileSync(yml)[0].repo_token; - } - } catch(ex){ - console.log("Repo token could not be determined. Continuing without it."); - } - } - - convertLcovToCoveralls(input, libDir, repo_token, function(err, postData){ - if (err){ - throw err; - } - sendToCoveralls(postData, function(err, response, body){ - if (err){ - throw err; - } - if (response.statusCode >= 400){ - throw "Bad response: " + response.statusCode + " " + body; - } - console.log(response.statusCode); - console.log(body); - }); - }); - -}; |
