diff --git a/src/config-types.ts b/src/config-types.ts index fc59333d4..923d38163 100644 --- a/src/config-types.ts +++ b/src/config-types.ts @@ -2,6 +2,7 @@ import { ServerOptions } from 'https'; export interface Config { mode: 'test' | 'development'; + dataDir: string; port: number; hostname: string; serverFiles: string; diff --git a/src/load-config.js b/src/load-config.js index a4714d1ed..d3cc5dd05 100644 --- a/src/load-config.js +++ b/src/load-config.js @@ -44,7 +44,7 @@ if (process.env.ACTUAL_CONFIG_PATH) { userConfig = parseJSON(configFile, true); } -/** @type {Omit} */ +/** @type {Omit} */ let defaultConfig = { port: 5006, hostname: '::', @@ -67,6 +67,7 @@ let config; if (process.env.NODE_ENV === 'test') { config = { mode: 'test', + dataDir: projectRoot, serverFiles: path.join(projectRoot, 'test-server-files'), userFiles: path.join(projectRoot, 'test-user-files'), ...defaultConfig, @@ -75,6 +76,7 @@ if (process.env.NODE_ENV === 'test') { config = { mode: 'development', ...defaultConfig, + dataDir: defaultDataDir, serverFiles: path.join(defaultDataDir, 'server-files'), userFiles: path.join(defaultDataDir, 'user-files'), ...(userConfig || {}), diff --git a/src/migrations.js b/src/migrations.js index 66f59d4a6..964e1f28b 100644 --- a/src/migrations.js +++ b/src/migrations.js @@ -1,4 +1,5 @@ import migrate from 'migrate'; +import path from 'node:path'; import config from './load-config.js'; export default function run(direction = 'up') { @@ -9,7 +10,9 @@ export default function run(direction = 'up') { return new Promise((resolve) => migrate.load( { - stateStore: `.migrate${config.mode === 'test' ? '-test' : ''}`, + stateStore: `${path.join(config.dataDir, '.migrate')}${ + config.mode === 'test' ? '-test' : '' + }`, }, (err, set) => { if (err) {