From 7f18a96adedae3400aeaec472b2add5733141d03 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sat, 15 Aug 2020 13:40:04 +0200 Subject: [PATCH] :wrench: Handle optional parameters --- index.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index ec85d06..78f3ac7 100644 --- a/index.js +++ b/index.js @@ -20,44 +20,44 @@ try { const cacheSeconds = core.getInput('cache-seconds'); - if (labelColor != undefined) { + if (labelColor != '') { description.labelColor = labelColor; } - if (color != undefined) { + if (color != '') { description.labelColor = color; } - if (isError != undefined) { + if (isError != '') { description.isError = isError; } - if (namedLogo != undefined) { + if (namedLogo != '') { description.namedLogo = namedLogo; } - if (logoSvg != undefined) { + if (logoSvg != '') { description.logoSvg = logoSvg; } - if (logoColor != undefined) { + if (logoColor != '') { description.logoColor = logoColor; } - if (logoWidth != undefined) { - description.logoWidth = logoWidth; + if (logoWidth != '') { + description.logoWidth = parseInt(logoWidth); } - if (logoPosition != undefined) { + if (logoPosition != '') { description.logoPosition = logoPosition; } - if (style != undefined) { + if (style != '') { description.style = style; } - if (cacheSeconds != undefined) { - description.cacheSeconds = cacheSeconds; + if (cacheSeconds != '') { + description.cacheSeconds = parseInt(cacheSeconds); } let data = {files: {}}; @@ -66,9 +66,6 @@ try { }; data = JSON.stringify(data); - console.log('test 0'); - - const req = http.request( { host: 'api.github.com', @@ -82,7 +79,6 @@ try { } }, res => { - console.log('foooo!'); let body = ''; res.on('data', data => { @@ -94,13 +90,9 @@ try { }); }); - console.log('test 1'); req.write(data); - console.log('test 2'); req.end(); - console.log('test 3'); - } catch (error) { core.setFailed(error); } \ No newline at end of file