From 3063b1b694d4d446b1c8a788710e957ae90f986a Mon Sep 17 00:00:00 2001 From: Nadav Ivgi Date: Tue, 12 Feb 2019 15:33:15 +0200 Subject: [PATCH] Fix mining pool config path This wasn't detected correctly if the btc-rpc-explorer executable was started outside the source code directory. --- app.js | 2 +- bin/refresh-mining-pool-configs.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 493336e..d9270ac 100755 --- a/app.js +++ b/app.js @@ -216,7 +216,7 @@ function logBlockStats() { function loadMiningPoolConfigs() { global.miningPoolsConfigs = []; - var miningPoolsConfigDir = path.join(process.cwd(), "public", "txt", "mining-pools-configs", global.coinConfig.ticker); + var miningPoolsConfigDir = path.join(__dirname, "public", "txt", "mining-pools-configs", global.coinConfig.ticker); fs.readdir(miningPoolsConfigDir, function(err, files) { if (err) { diff --git a/bin/refresh-mining-pool-configs.js b/bin/refresh-mining-pool-configs.js index db1c574..ea53481 100644 --- a/bin/refresh-mining-pool-configs.js +++ b/bin/refresh-mining-pool-configs.js @@ -13,7 +13,7 @@ async function refreshMiningPoolsForCoin(coinName) { console.log(`Refreshing mining pools for ${coinName}...`); if (coins[coinName].miningPoolsConfigUrls) { - var miningPoolsConfigDir = path.join(process.cwd(), "public", "txt", "mining-pools-configs", coinName); + var miningPoolsConfigDir = path.join(__dirname, "..", "public", "txt", "mining-pools-configs", coinName); fs.readdir(miningPoolsConfigDir, function(err, files) { if (err) { reject(`Unable to delete existing files from '${miningPoolsConfigDir}'`); @@ -59,8 +59,8 @@ async function refreshMiningPoolConfig(coinName, index, url) { if (!error && response && response.statusCode && response.statusCode == 200) { var responseBody = JSON.parse(body); - var filename = path.join(process.cwd(), "public", "txt", "mining-pools-configs", coinName, index + ".json"); - + var filename = path.join(__dirname, "..", "public", "txt", "mining-pools-configs", coinName, index + ".json"); + fs.writeFileSync(filename, body, function(err) { console.log(`Error writing file '${filename}': ${err}`); });