Skip to content

Commit

Permalink
Make running app.js cwd agnostic, extend config to allow changing dat…
Browse files Browse the repository at this point in the history
…aDir (#341)
  • Loading branch information
matt-fidd authored Apr 19, 2024
1 parent ae0faf4 commit 44c7b4e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ServerOptions } from 'https';
export interface Config {
mode: 'test' | 'development';
dataDir: string;
projectRoot: string;
port: number;
hostname: string;
serverFiles: string;
Expand Down
4 changes: 4 additions & 0 deletions src/load-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ if (process.env.ACTUAL_CONFIG_PATH) {
`loading config from ACTUAL_CONFIG_PATH: '${process.env.ACTUAL_CONFIG_PATH}'`,
);
userConfig = parseJSON(process.env.ACTUAL_CONFIG_PATH);

defaultDataDir = userConfig.dataDir ?? defaultDataDir;
} else {
let configFile = path.join(projectRoot, 'config.json');

Expand Down Expand Up @@ -60,6 +62,7 @@ let defaultConfig = {
syncEncryptedFileSizeLimitMB: 50,
fileSizeLimitMB: 20,
},
projectRoot,
};

/** @type {import('./config-types.js').Config} */
Expand Down Expand Up @@ -120,6 +123,7 @@ const finalConfig = {

debug(`using port ${finalConfig.port}`);
debug(`using hostname ${finalConfig.hostname}`);
debug(`using data directory ${finalConfig.dataDir}`);
debug(`using server files directory ${finalConfig.serverFiles}`);
debug(`using user files directory ${finalConfig.userFiles}`);
debug(`using web root directory ${finalConfig.webRoot}`);
Expand Down
1 change: 1 addition & 0 deletions src/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function run(direction = 'up') {
stateStore: `${path.join(config.dataDir, '.migrate')}${
config.mode === 'test' ? '-test' : ''
}`,
migrationsDirectory: `${path.join(config.projectRoot, 'migrations')}`,
},
(err, set) => {
if (err) {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/341.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [matt-fidd]
---

Make running app.js cwd agnostic and extend config options to allow changing dataDir

0 comments on commit 44c7b4e

Please sign in to comment.