From 7b29d8844f93245e41228f7d05d1dfbbfb97cc43 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Fri, 25 Mar 2022 19:29:09 +0100 Subject: [PATCH 1/3] Update nodeEngineCheck.js --- ci/nodeEngineCheck.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ci/nodeEngineCheck.js b/ci/nodeEngineCheck.js index da68f314b1..f60906960f 100644 --- a/ci/nodeEngineCheck.js +++ b/ci/nodeEngineCheck.js @@ -2,6 +2,7 @@ const core = require('@actions/core'); const semver = require('semver'); const fs = require('fs').promises; const path = require('path'); +const { createCipheriv } = require('crypto'); /** * This checks whether any package dependency requires a minimum node engine @@ -75,17 +76,20 @@ class NodeEngineCheck { // For each file for (const file of files) { - // Get node version const contentString = await fs.readFile(file, 'utf-8'); - const contentJson = JSON.parse(contentString); - const version = ((contentJson || {}).engines || {}).node; - - // Add response - response.push({ - file: file, - nodeVersion: version - }); + try { + const contentJson = JSON.parse(contentString); + const version = ((contentJson || {}).engines || {}).node; + + // Add response + response.push({ + file: file, + nodeVersion: version + }); + } catch(e) { + core.warning(`Ignoring file because it is not valid JSON: ${file}`); + } } // If results should be cleaned by removing undefined node versions From a8e15592d405a430e3c5aacc9ffa9d7494838f15 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Fri, 25 Mar 2022 19:32:37 +0100 Subject: [PATCH 2/3] Update nodeEngineCheck.js --- ci/nodeEngineCheck.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/nodeEngineCheck.js b/ci/nodeEngineCheck.js index f60906960f..2f6ca5c620 100644 --- a/ci/nodeEngineCheck.js +++ b/ci/nodeEngineCheck.js @@ -88,6 +88,7 @@ class NodeEngineCheck { nodeVersion: version }); } catch(e) { + console.log(`Ignoring file because it is not valid JSON: ${file}`); core.warning(`Ignoring file because it is not valid JSON: ${file}`); } } From 744b54ce5cb1d147de072a45e0f8090c04f78403 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Fri, 25 Mar 2022 19:36:57 +0100 Subject: [PATCH 3/3] lint fix --- ci/nodeEngineCheck.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/nodeEngineCheck.js b/ci/nodeEngineCheck.js index 2f6ca5c620..a68f2c593c 100644 --- a/ci/nodeEngineCheck.js +++ b/ci/nodeEngineCheck.js @@ -2,7 +2,6 @@ const core = require('@actions/core'); const semver = require('semver'); const fs = require('fs').promises; const path = require('path'); -const { createCipheriv } = require('crypto'); /** * This checks whether any package dependency requires a minimum node engine