Allow overriding TASKRC/TASKDATA using environment variables

This commit is contained in:
Zsombor Welker 2022-04-19 13:25:19 +02:00
parent 1d79a90ffb
commit 35a5363628
2 changed files with 9 additions and 4 deletions

View file

@ -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

View file

@ -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;