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

Commit

Permalink
Fix broken gcov command
Browse files Browse the repository at this point in the history
The gcov command can't be generated if none of the gcov options are
given on the command line, since sanitizeVar() will throw an exception
when given 'undefined' as input. This allows sanitizeVar() to accept an
input of 'undefined'.
  • Loading branch information
ptomato committed Sep 9, 2020
1 parent ebe132e commit 764a681
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/codecov.js
Expand Up @@ -556,6 +556,9 @@ var upload = function(args, on_success, on_failure) {
}

function sanitizeVar(arg) {
if (!arg) {
return ''
}
return arg.replace(/&/g, '')
}

Expand Down
6 changes: 6 additions & 0 deletions test/index.test.js
Expand Up @@ -282,4 +282,10 @@ describe('Codecov', function() {
'real run unsafe command'
)
})

it('gracefully sanitizes undefined', function() {
expect(function() {
codecov.sanitizeVar(undefined)
}).not.toThrow()
})
})

0 comments on commit 764a681

Please sign in to comment.