From 35a5363628b25bc9ed433f7261f573b892d553eb Mon Sep 17 00:00:00 2001 From: Zsombor Welker Date: Tue, 19 Apr 2022 13:25:19 +0200 Subject: [PATCH] Allow overriding TASKRC/TASKDATA using environment variables --- README.md | 6 ++++++ backend/src/taskwarrior.ts | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 80ca724..303e7ea 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,12 @@ Then install nginx or other web servers to server frontend and proxy requests to backend (you can refer to `nginx/nginx.conf`). +### Configuration + +The following environment variable may be set: + * `TASKRC` - the location of the `.taskrc` file, `/.taskrc` by default when run in _production_ mode + * `TASKDATA` - the location of the `.task` directory, `/.task` by default when run in _production_ mode + ## Development diff --git a/backend/src/taskwarrior.ts b/backend/src/taskwarrior.ts index 36f7c4a..e0772e7 100644 --- a/backend/src/taskwarrior.ts +++ b/backend/src/taskwarrior.ts @@ -2,10 +2,9 @@ import { TaskwarriorLib } from 'taskwarrior-lib'; import * as path from 'path'; const prod = process.env.NODE_ENV === 'production'; +const taskRc = process.env.TASKRC || (prod ? '/.taskrc' : path.join(__dirname, '../test/.taskrc')); +const taskData = process.env.TASKDATA || (prod ? '/.task' : path.join(__dirname, '../test/.task')); -const taskwarrior = new TaskwarriorLib( - prod ? '/.taskrc' : path.join(__dirname, '../test/.taskrc'), - prod ? '/.task' : path.join(__dirname, '../test/.task'), -); +const taskwarrior = new TaskwarriorLib(taskRc, taskData); export default taskwarrior;