module FoundersTemplate::Utils

Public Instance Methods

add_to_envrc(variables) click to toggle source
# File lib/founders_template/utils.rb, line 5
def add_to_envrc(variables)
  create_file '.envrc' unless File.exist?('.envrc')

  variables.each do |name, value|
    name = name.to_s
    append_to_file '.envrc', "export #{name}=#{value}\n"
    ENV[name] = value
  end

  run 'direnv allow .'
end
check_command(command) click to toggle source
# File lib/founders_template/utils.rb, line 17
def check_command(command)
  return true if system_command?(command)

  say_status :missing, command
  false
end
system_command?(command) click to toggle source
# File lib/founders_template/utils.rb, line 24
def system_command?(command)
  system("which #{Shellwords.escape(command)} > /dev/null 2>&1")
end
template_file(template_file) click to toggle source
# File lib/founders_template/utils.rb, line 28
def template_file(template_file)
  template template_file.template_file,
           template_file.output_file,
           context: template_file.binding_for_render
end