mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-17 10:58:31 -07:00
a54e256b40
Group configuration via configuration.yaml and group state.
34 lines
744 B
JavaScript
34 lines
744 B
JavaScript
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
let dataPath = null;
|
|
|
|
function load() {
|
|
if (process.env.ZIGBEE2MQTT_DATA) {
|
|
dataPath = process.env.ZIGBEE2MQTT_DATA;
|
|
} else {
|
|
dataPath = path.join(__dirname, '..', '..', 'data');
|
|
dataPath = path.normalize(dataPath);
|
|
}
|
|
}
|
|
|
|
load();
|
|
|
|
function joinPathStorage(file) {
|
|
const storagePath = path.join(dataPath, '.storage');
|
|
if (!fs.existsSync(storagePath)) {
|
|
fs.mkdirSync(storagePath);
|
|
}
|
|
|
|
return path.join(storagePath, file);
|
|
}
|
|
|
|
module.exports = {
|
|
joinPath: (file) => path.join(dataPath, file),
|
|
joinPathStorage: (file) => joinPathStorage(file),
|
|
getPath: () => dataPath,
|
|
|
|
// For test only.
|
|
_reload: () => load(),
|
|
};
|