From 764a6819d9f515d4d9753e13f29bc7e11e98375d Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 6 Mar 2020 11:39:03 -0800 Subject: [PATCH] Fix broken gcov command 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'. --- lib/codecov.js | 3 +++ test/index.test.js | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/codecov.js b/lib/codecov.js index ad0cb2a2..bb830b79 100644 --- a/lib/codecov.js +++ b/lib/codecov.js @@ -556,6 +556,9 @@ var upload = function(args, on_success, on_failure) { } function sanitizeVar(arg) { + if (!arg) { + return '' + } return arg.replace(/&/g, '') } diff --git a/test/index.test.js b/test/index.test.js index 7fd11431..77d4b5ed 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -282,4 +282,10 @@ describe('Codecov', function() { 'real run unsafe command' ) }) + + it('gracefully sanitizes undefined', function() { + expect(function() { + codecov.sanitizeVar(undefined) + }).not.toThrow() + }) })