2018-05-11 20:04:15 -07:00
|
|
|
const path = require('path');
|
|
|
|
|
2018-05-12 01:58:06 -07:00
|
|
|
let dataPath = null;
|
|
|
|
|
2019-02-24 07:49:41 -07:00
|
|
|
function load() {
|
|
|
|
if (process.env.ZIGBEE2MQTT_DATA) {
|
|
|
|
dataPath = process.env.ZIGBEE2MQTT_DATA;
|
|
|
|
} else {
|
|
|
|
dataPath = path.join(__dirname, '..', '..', 'data');
|
|
|
|
dataPath = path.normalize(dataPath);
|
|
|
|
}
|
2018-05-11 20:04:15 -07:00
|
|
|
}
|
|
|
|
|
2019-02-24 07:49:41 -07:00
|
|
|
load();
|
|
|
|
|
2018-05-11 20:04:15 -07:00
|
|
|
module.exports = {
|
2018-05-17 08:20:46 -07:00
|
|
|
joinPath: (file) => path.join(dataPath, file),
|
2018-08-05 09:55:26 -07:00
|
|
|
getPath: () => dataPath,
|
2019-02-24 07:49:41 -07:00
|
|
|
|
|
|
|
// For test only.
|
|
|
|
_reload: () => load(),
|
2018-05-17 08:20:46 -07:00
|
|
|
};
|