From 110333f48802c15e52380bb114c709966504ea7f Mon Sep 17 00:00:00 2001 From: xmz Date: Fri, 19 Apr 2024 14:47:36 +0800 Subject: [PATCH] fix config.js --- src/config.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/config.js b/src/config.js index ee508fb..cb2ddac 100644 --- a/src/config.js +++ b/src/config.js @@ -7,8 +7,7 @@ const inputSshKeyPath = 'SSH_PRIVATE_KEY_PATH'; const readConfig = (configPath) => { if (existsSync(configPath)) { const message = `⚠️ [FILE] ${configPath} Required file exist.`; - console.warn(message); - return null; + throw new Error(message); } try { console.log(`[FILE] reading ${configPath} file ...`); @@ -16,24 +15,21 @@ const readConfig = (configPath) => { return JSON.parse(fileContents); } catch (error) { const message = `⚠️[FILE] reading file error. configPath: ${configPath}, message: ${error.message}`; - console.warn(message); - return null; + throw new Error(message); } }; const readSshKey = (SshKeyPath) => { if (existsSync(SshKeyPath)) { const message = `⚠️ [FILE] ${SshKeyPath} Required file exist.`; - console.warn(message); - return null; + throw new Error(message); } try { console.log(`[FILE] reading ${SshKeyPath} file ...`); return readFileSync(SshKeyPath, 'utf8'); } catch (error) { const message = `⚠️[FILE] reading file error. configPath: ${SshKeyPath}, message: ${error.message}`; - console.warn(message); - return ''; + throw new Error(message); } };