Class: Envs::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/envs/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
9
10
# File 'lib/envs/runner.rb', line 5

def initialize(opts)
  @root = opts[:root]
  Sickill::Rainbow.enabled = !opts[:no_color]
  @count = 0
  @synced_dirs = []
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/envs/runner.rb', line 12

def run
  puts "Envs! #{VERSION}"

  gitignore = File.join(@root, ".gitignore")
  if File.exist?(gitignore)
    warn "You should probably add .env to your gitignore file fool!".foreground(:red) unless File.read(gitignore).split(/\n/).include?('.env')
  end

  Dir[File.join(@root, "**/.env")].each do |dir|
    sync File.dirname(dir)
  end
  Dir[File.join(@root, "**/.env.default")].each do |dir|
    sync File.dirname(dir)
  end

  puts "Synced #{@count.to_s.foreground(:green)} values in #{@synced_dirs.size.to_s.foreground(:green)} dirs. Your welcome."
end