diff --git a/package.json b/package.json index ce88b5e..03d3181 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "home-automation-pubnub", - "version": "0.4.7", + "version": "0.5.0", "description": "PubNub wrapper for the Home Automation project.", "author": "Oron Nadiv (https://github.com/OronNadiv/)", "homepage": "https://github.com/OronNadiv/home-automation-pubnub/", @@ -13,7 +13,7 @@ }, "license": "AGPL-3.0", "engines": { - "node": ">=4 <9", + "node": ">=4 <10", "npm": ">=2 <6" }, "main": "dist/index.js", diff --git a/src/config.js b/src/config.js index 8864882..dab2adf 100644 --- a/src/config.js +++ b/src/config.js @@ -2,29 +2,35 @@ import DebugLib from 'debug' const error = DebugLib('ha:pubnub:config:error') -export const publishKey = process.env.PUBNUB_PUBLISH_KEY +export const publishKey = process.env.PUBNUB_PUBLISH_KEY || process.env.REACT_APP_PUBNUB_PUBLISH_KEY if (!publishKey) { - error('PubNub publish key could not be found in the environment variable. Please set \'PUBNUB_PUBLISH_KEY\'.') - if (process) { + const message = 'PubNub publish key could not be found in the environment variable. Please set \'PUBNUB_PUBLISH_KEY\' or \'REACT_APP_PUBNUB_PUBLISH_KEY\'.' + error(message) + if (process && process.exit) { process.exit(100) } + console.error(message) } -export const subscribeKey = process.env.PUBNUB_SUBSCRIBE_KEY +export const subscribeKey = process.env.PUBNUB_SUBSCRIBE_KEY || process.env.REACT_APP_PUBNUB_SUBSCRIBE_KEY if (!subscribeKey) { - error('PubNub subscribe key could not be found in the environment variable. Please set \'PUBNUB_SUBSCRIBE_KEY\'.') - if (process) { + const message = 'PubNub subscribe key could not be found in the environment variable. Please set \'PUBNUB_SUBSCRIBE_KEY\' or \'REACT_APP_PUBNUB_SUBSCRIBE_KEY\'.' + error(message) + if (process && process.exit) { process.exit(200) } + console.error(message) } export const secretKey = () => { const res = process.env.PUBNUB_SECRET_KEY if (!res) { - error('PubNub secret key could not be found in the environment variable. Please set \'PUBNUB_SECRET_KEY\'.') - if (process) { + const message = 'PubNub secret key could not be found in the environment variable. Please set \'PUBNUB_SECRET_KEY\'.' + error(message) + if (process && process.exit) { process.exit(300) } + console.error(message) } return res }