Skip to content

Instantly share code, notes, and snippets.

@khopkins218
Last active April 12, 2019 08:15
Show Gist options
  • Save khopkins218/b1a6fdb5df8a4d4fa93e2b79d8dc9b1a to your computer and use it in GitHub Desktop.
Save khopkins218/b1a6fdb5df8a4d4fa93e2b79d8dc9b1a to your computer and use it in GitHub Desktop.
namespace :client do
desc 'Start the client React app development server'
task start: [:environment] do
system_command "#{env_vars} yarn start"
end
# Send the value to the client
def client_env_vars
%w[
GOOGLE_ANALYTICS_ID
MIXPANEL_KEY
SENTRY_JS_KEY
SENTRY_JS_ID
]
end
def env_vars
client_env_vars.reduce('') do |str, var|
env_value = ENV.fetch(var, '').presence
str << "REACT_APP_#{var}=#{env_value} " if env_value
str
end
end
def system_command(command)
puts command
system command
raise if $? != 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment