Enhance settings handling

This commit is contained in:
Jesse Cotton 2018-04-02 21:37:21 -07:00
parent 3f4628220b
commit 8abb861cab
No known key found for this signature in database
GPG Key ID: 731B5A1B4C1DDCD3

View File

@ -11,13 +11,12 @@ let ORVIBO_KEY = Settings.ORVIBO_KEY;
let LOG_PACKET = Settings.LOG_PACKET;
let PLUG_INFO = Settings.plugInfo;
const Orvibo = function(userSettings) {
const Orvibo = function(userSettings = {}) {
// Allow user to pass in settings
if (userSettings != null) {
ORVIBO_KEY = userSettings.ORVIBO_KEY;
LOG_PACKET = userSettings.LOG_PACKET;
PLUG_INFO = userSettings.plugInfo;
}
if('ORVIBO_KEY' in userSettings) ORVIBO_KEY = userSettings.ORVIBO_KEY;
if('plugInfo' in userSettings) PLUG_INFO = userSettings.plugInfo;
if('PLUG_INFO' in userSettings) PLUG_INFO = userSettings.PLUG_INFO;
if('LOG_PACKET' in userSettings) LOG_PACKET = userSettings.LOG_PACKET;
if (ORVIBO_KEY === '') {
logger.log('Please pass Orvibo PK key details via the constructor or add to OrviboSettings.js file. See Readme');