mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-17 02:48:31 -07:00
17 lines
388 B
JavaScript
17 lines
388 B
JavaScript
const yaml = require('js-yaml');
|
|
const fs = require('fs');
|
|
|
|
function readYaml(file) {
|
|
return yaml.safeLoad(fs.readFileSync(file, 'utf8'));
|
|
}
|
|
|
|
function readYamlIfExists(file) {
|
|
return fs.existsSync(file) ? readYaml(file) : null;
|
|
}
|
|
|
|
function writeYaml(file, content) {
|
|
fs.writeFileSync(file, yaml.safeDump(content));
|
|
}
|
|
|
|
module.exports = {readYaml, readYamlIfExists, writeYaml};
|