DEV Community

Discussion on: dotenv but 3 lines of ruby

Collapse
 
kwstannard profile image
Kelly Stannard

How about 3 lines or fairly readable ruby?

#!/usr/bin/env ruby

regexp = /^(\w+)=['"]?(.+?)['"]?$/

ENV.update File.read(".env").scan(regexp).to_h if File.exist?(".env")
exec(ENV, *ARGV)