mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-03-31 06:24:02 -04:00
27 lines
767 B
JavaScript
27 lines
767 B
JavaScript
/**
|
|
* Import base modules
|
|
*/
|
|
const fs = require('fs');
|
|
|
|
/**
|
|
* Get an option from external config (Home Assistant / Local Development)
|
|
*
|
|
* @param option
|
|
* @return {*|null}
|
|
*/
|
|
module.exports = (option) => {
|
|
// Check if Home Assistant config exists
|
|
if (fs.existsSync('/data/options.json')) {
|
|
const data = JSON.parse(fs.readFileSync('/data/options.json', 'utf-8'));
|
|
return typeof data[option] !== 'undefined' ? data[option] : null;
|
|
}
|
|
|
|
// Check if Local (Development) config exists
|
|
if (fs.existsSync(`${__dirname}/../.options.json`)) {
|
|
const data = JSON.parse(fs.readFileSync(`${__dirname}/../.options.json`, 'utf-8'));
|
|
return typeof data[option] !== 'undefined' ? data[option] : null;
|
|
}
|
|
|
|
return null;
|
|
};
|