@actual-app/sync-server 25.4.0-alpha.6 → 25.4.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59,8 +59,15 @@ if (values.version) {
59
59
  process.exit();
60
60
  }
61
61
 
62
- const setupDataDir = () => {
63
- if (!process.env.ACTUAL_DATA_DIR) {
62
+ const setupDataDir = (dataDir = undefined) => {
63
+ if (process.env.ACTUAL_DATA_DIR) {
64
+ return; // Env variables must not be overwritten
65
+ }
66
+
67
+ if (dataDir) {
68
+ process.env.ACTUAL_DATA_DIR = dataDir; // Use the dir specified
69
+ } else {
70
+ // Setup defaults
64
71
  if (existsSync('./data')) {
65
72
  // The default data directory exists - use it
66
73
  console.info('Found existing data directory');
@@ -74,7 +81,7 @@ const setupDataDir = () => {
74
81
 
75
82
  console.info(`Data directory: ${process.env.ACTUAL_DATA_DIR}`);
76
83
  }
77
- };
84
+ }
78
85
 
79
86
  if (values.config) {
80
87
  const configExists = existsSync(values.config);
@@ -87,12 +94,9 @@ if (values.config) {
87
94
  process.exit();
88
95
  } else {
89
96
  console.log(`Loading config from ${values.config}`);
90
- process.env.ACTUAL_CONFIG_PATH = values.config;
91
-
92
97
  const configJson = JSON.parse(readFileSync(values.config, 'utf-8'));
93
- if (!configJson.dataDir) {
94
- setupDataDir();
95
- }
98
+ process.env.ACTUAL_CONFIG_PATH = values.config;
99
+ setupDataDir(configJson.dataDir);
96
100
  }
97
101
  } else {
98
102
  // If no config is specified, check for a default config in the current directory
@@ -103,12 +107,9 @@ if (values.config) {
103
107
  console.info('Found config.json in the current directory');
104
108
  const configJson = JSON.parse(readFileSync(defaultConfigJsonFile, 'utf-8'));
105
109
  process.env.ACTUAL_CONFIG_PATH = defaultConfigJsonFile;
106
-
107
- if (!configJson.dataDir) {
108
- setupDataDir(); // No dataDir specified in config.json. Set it up
109
- }
110
+ setupDataDir(configJson.dataDir);
110
111
  } else {
111
- setupDataDir(); // No default config exists - setup data dir
112
+ setupDataDir(); // No default config exists - setup data dir with defaults
112
113
  }
113
114
  }
114
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actual-app/sync-server",
3
- "version": "25.4.0-alpha.6",
3
+ "version": "25.4.0-alpha.7",
4
4
  "license": "MIT",
5
5
  "description": "actual syncing server",
6
6
  "bin": {