-
-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added fix for #181 but without any changes to test #183
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,8 +59,6 @@ var coverage = pipeToService | |
var coverageReport | ||
|
||
var nycBin = require.resolve('nyc/bin/nyc.js') | ||
var coverallsBin = require.resolve('coveralls/bin/coveralls.js') | ||
var codecovBin = require.resolve('codecov.io/bin/codecov.io.js') | ||
|
||
for (var i = 0; i < args.length; i++) { | ||
var arg = args[i] | ||
|
@@ -228,39 +226,45 @@ if (coverageReport && !global.__coverage__ && files.length === 0) { | |
var args = [nycBin, 'report', '--reporter', coverageReport] | ||
var child | ||
|
||
// automatically hook into coveralls | ||
// automatically hook into coveralls and/or codecov | ||
if (coverageReport === 'text-lcov' && pipeToService) { | ||
child = spawn(node, args) | ||
var covBin, covName | ||
|
||
if (process.env.COVERALLS_REPO_TOKEN) { | ||
covBin = coverallsBin | ||
covName = 'Coveralls' | ||
} else if (process.env.CODECOV_TOKEN) { | ||
covBin = codecovBin | ||
covName = 'Codecov' | ||
} | ||
|
||
var ca = spawn(node, [covBin], { | ||
stdio: [ 'pipe', 1, 2 ], | ||
env: process.env | ||
}) | ||
child.stdout.pipe(ca.stdin) | ||
ca.on('close', function (code, signal) { | ||
if (signal) | ||
process.kill(process.pid, signal) | ||
else if (code) | ||
process.exit(code) | ||
else | ||
console.log('Successfully piped to ' + covName) | ||
var services = [ | ||
process.env.COVERALLS_REPO_TOKEN && { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed since we have the services array |
||
covBin: require.resolve('coveralls/bin/coveralls.js') | ||
, covName: 'Coveralls' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
, process.env.CODECOV_TOKEN && { | ||
covBin: require.resolve('codecov.io/bin/codecov.io.js') | ||
, covName: 'Codecov' | ||
} | ||
].filter(function(s) { | ||
return !!s // remove undefined services | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved inside the forEach |
||
signalExit(function (code, signal) { | ||
child.kill('SIGHUP') | ||
ca.kill('SIGHUP') | ||
|
||
services.forEach(function(s) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. forEach is new |
||
var ca = spawn(node, [s.covBin], { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The content is pretty much the same as it has always been. Since the forEach argument is a function, we get a function scope environment. That is, each variable is stored in the environment which in turns is stored on the heap. The only thing that can lead to concern is the question of when the signalExit function argument is run. If we got 2 environments and both have access to child and they both call child.kill('SIGHUP'), is the code then racy? I haven't seen it but I also don't know the internals of signal-exit. See the "Environments: Managing Variables" section of Speaking JavaScript for an explanation of javascript environment. |
||
stdio: [ 'pipe', 1, 2 ], | ||
env: process.env | ||
}) | ||
child.stdout.pipe(ca.stdin) | ||
ca.on('close', function (code, signal) { | ||
if (signal) | ||
process.kill(process.pid, signal) | ||
else if (code) | ||
process.exit(code) | ||
else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved inside the forEach |
||
console.log('Successfully piped to ' + s.covName) | ||
}) | ||
signalExit(function (code, signal) { | ||
child.kill('SIGHUP') | ||
ca.kill('SIGHUP') | ||
}) | ||
}) | ||
} else { | ||
// otherwise just run the reporter | ||
var child = fg(node, args) | ||
child = fg(node, args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why |
||
if (coverageReport === 'lcov') { | ||
child.on('exit', function () { | ||
opener('coverage/lcov-report/index.html') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant, since the introduction of the services array