Class: Discharger::SetupRunner::Commands::EnvCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Discharger::SetupRunner::Commands::EnvCommand
show all
- Defined in:
- lib/discharger/setup_runner/commands/env_command.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
#app_root, #config, #logger
Instance Method Summary
collapse
Methods inherited from BaseCommand
#initialize
Instance Method Details
#can_execute? ⇒ Boolean
32
33
34
|
# File 'lib/discharger/setup_runner/commands/env_command.rb', line 32
def can_execute?
File.exist?(".env.example")
end
|
#description ⇒ Object
36
37
38
|
# File 'lib/discharger/setup_runner/commands/env_command.rb', line 36
def description
"Setup environment file"
end
|
#execute ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/discharger/setup_runner/commands/env_command.rb', line 10
def execute
if File.exist?(".env")
unless ENV["QUIET_SETUP"] || ENV["DISABLE_OUTPUT"]
require "rainbow"
puts Rainbow(" → .env file already exists. Skipping.").yellow
end
return
end
unless File.exist?(".env.example")
unless ENV["QUIET_SETUP"] || ENV["DISABLE_OUTPUT"]
require "rainbow"
puts Rainbow(" → WARNING: .env.example not found. Skipping .env creation").yellow
end
return
end
simple_action("Creating .env from .env.example") do
FileUtils.cp(".env.example", ".env")
end
end
|