From 062cfac0ca25a5b59852f430883e921cc56bafa7 Mon Sep 17 00:00:00 2001 From: Gabriel Rivero Date: Tue, 24 Sep 2024 17:56:59 +0200 Subject: [PATCH] Some fix config.js --- config/config.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/config/config.js b/config/config.js index 35db7c2..d1bf67c 100644 --- a/config/config.js +++ b/config/config.js @@ -6,9 +6,21 @@ import * as dotenv from 'dotenv'; dotenv.config(); const mnemonic_path= "config/secret/mnemonic" -const mnemonics = fs.readFileSync(mnemonic_path, 'utf8').trim().split('\n'); -console.log("==================================================================") -console.log(`faucet mnemonic: ${mnemonics[0].substring(1, 15)} ...`) +let mnemonics; +try { + mnemonics = fs.readFileSync(mnemonic_path, 'utf8').trim().split('\n'); + if (mnemonics.length === 0) throw new Error("Mnemonic file is empty"); +} catch (err) { + console.error(`Error reading mnemonics from ${mnemonic_path}:`, err); + process.exit(1); +} + +console.log("=================================================================="); +if (mnemonics[0].length >= 15) { + console.log(`faucet mnemonic: ${mnemonics[0].substring(1, 15)} ...`); +} else { + console.log(`faucet mnemonic: ${mnemonics[0]} ...`); +} export default {