Files
zigbee2mqtt/lib/util/data.ts
T
github-actions[bot] 09383877b0 Update dependencies (#9444)
* Update dependencies

* Fix lint

Co-authored-by: Koenkk <Koenkk@users.noreply.github.com>
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
2021-11-01 18:10:54 +01:00

30 lines
587 B
TypeScript

import path from 'path';
let dataPath: string = null;
function load(): void {
if (process.env.ZIGBEE2MQTT_DATA) {
dataPath = process.env.ZIGBEE2MQTT_DATA;
} else {
dataPath = path.join(__dirname, '..', '..', 'data');
dataPath = path.normalize(dataPath);
}
}
load();
function joinPath(file: string): string {
return path.join(dataPath, file);
}
function getPath(): string {
return dataPath;
}
// eslint-disable-next-line camelcase
function testingOnlyReload(): void {
load();
}
export default {joinPath, getPath, testingOnlyReload};