Skip to content

Commit 40fd80f

Browse files
committed
avoid error when config.json not exist
1 parent 3f3b5ed commit 40fd80f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/cache.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const fs = require("fs");
2-
const config = JSON.parse(fs.readFileSync("./config.json"));
2+
let config = {};
3+
4+
if (fs.existsSync("./config.json")) {
5+
config = JSON.parse(fs.readFileSync("./config.json"));
6+
}
37

48
// global cache
59
const cache = {
@@ -43,7 +47,7 @@ const cache = {
4347
sell: { success: 0, fail: 0 },
4448
},
4549
ui: {
46-
defaultColor: config.ui.defaultColor,
50+
defaultColor: config?.ui?.defaultColor || "cyan",
4751
showPerformanceOfRouteCompChart: false,
4852
showProfitChart: true,
4953
showTradeHistory: true,
@@ -62,11 +66,11 @@ const cache = {
6266
e: false,
6367
r: false,
6468
},
65-
tradingEnabled: config.tradingEnabled,
69+
tradingEnabled: config?.tradingEnabled || false,
6670
swappingRightNow: false,
6771
fetchingResultsFromSolscan: false,
6872
fetchingResultsFromSolscanStart: 0,
69-
tradingStrategy: config.tradingStrategy,
73+
tradingStrategy: config?.tradingStrategy || "arbitrage",
7074
tradeHistory: [],
7175
performanceOfTxStart: 0,
7276
availableRoutes: {

0 commit comments

Comments
 (0)