Last active
April 12, 2019 08:15
-
-
Save khopkins218/b1a6fdb5df8a4d4fa93e2b79d8dc9b1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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