Skip to content

A local-first personal finance app

Fix config file not being loaded from the project root by default (#249)

Constantin Mihaiad65fcdffc40
diff --git a/src/load-config.js b/src/load-config.js
index 0e5f10ad5a..947c8c86d3 100644
--- a/src/load-config.js
+++ b/src/load-config.js
@@ -34,8 +34,14 @@ if (process.env.ACTUAL_CONFIG_PATH) {
);
userConfig = parseJSON(process.env.ACTUAL_CONFIG_PATH);
} else {
- debug(`loading config from default path: '${defaultDataDir}/config.json'`);
- userConfig = parseJSON(path.join(defaultDataDir, 'config.json'), true);
+ let configFile = path.join(projectRoot, 'config.json');
+
+ if (!fs.existsSync(configFile)) {
+ configFile = path.join(defaultDataDir, 'config.json');
+ }
+
+ debug(`loading config from default path: '${configFile}'`);
+ userConfig = parseJSON(configFile, true);
}
/** @type {Omit<import('./config-types.js').Config, 'mode' | 'serverFiles' | 'userFiles'>} */
diff --git a/upcoming-release-notes/249.md b/upcoming-release-notes/249.md
new file mode 100644
index 0000000000..7f386aed68
--- /dev/null
+++ b/upcoming-release-notes/249.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [UnexomWid]
+---
+
+Fix config file not being loaded from the project root by default
\ No newline at end of file