From 95a80a0e757647f84515e7bc7208f18b875d4111 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 21 Nov 2018 10:35:53 -0800 Subject: Shorter validateRollbarPresence logic --- packages/instant/webpack.config.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'packages') diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index defdde250..adc1cb000 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -66,21 +66,14 @@ const getRollbarPlugin = environmentName => { }; return new RollbarSourceMapPlugin(rollbarPluginOptions); }; - -const validateRollbarPresence = (environmentName, rollbarPlugin) => { +const validateRollbarPresence = (environmentName, rollbarEnabled, rollbarSourceMapPlugin) => { const requiresRollbar = environmentName === 'dogfood' || environmentName === 'staging'; - if (!requiresRollbar) { return; } - - if (!process.env[ROLLBAR_CLIENT_TOKEN_ENV_NAME]) { - throw new Error(`${ROLLBAR_CLIENT_TOKEN_ENV_NAME} must be set for ${environmentName}`); - } - - if (!rollbarPlugin) { + if (!rollbarEnabled || !rollbarSourceMapPlugin) { throw new Error( - `Please set rollbar env var ${ROLLBAR_PUBLISH_TOKEN_ENV_NAME} to a Rollbar project access token with post_server_item permissions to deploy source maps to ${environmentName}`, + `Rollbar env vars must be set to build for ${environmentName}. Please set ${ROLLBAR_CLIENT_TOKEN_ENV_NAME} to a rollbar access token with post_client_item permissions, and ${ROLLBAR_PUBLISH_TOKEN_ENV_NAME} to a rollbar access token with post_server_item permissions.`, ); } }; @@ -115,7 +108,7 @@ module.exports = (env, argv) => { } else { console.log('Not using rollbar source map plugin'); } - validateRollbarPresence(environmentName, rollbarPlugin); + validateRollbarPresence(environmentName, envVars['ROLLBAR_ENABLED'], rollbarPlugin); const config = { entry: { -- cgit v1.2.3