Skip to content

Commit b88eaf8

Browse files
committed
standardize all command running through exec
1 parent 74547ad commit b88eaf8

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/procodile/cli.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ def dispatch(command)
365365
# Run a command with a procodile environment
366366
#
367367
desc "Execute a command within the environment"
368-
command def exec
369-
desired_command = ARGV.drop(1).join(' ')
368+
command def exec(command = nil)
369+
desired_command = command || ARGV.drop(1).join(' ')
370370

371371
if prefix = @config.exec_prefix
372372
desired_command = "#{prefix} #{desired_command}"
@@ -375,8 +375,14 @@ def dispatch(command)
375375
if desired_command.length == 0
376376
raise Error, "You need to specify a command to run (e.g. procodile run -- rake db:migrate)"
377377
else
378+
environment = @config.environment_variables
379+
puts "Running with #{desired_command.color(33)}"
380+
for key, value in environment
381+
puts " #{key.color(34)} #{value}"
382+
end
383+
378384
begin
379-
Kernel.exec(@config.environment_variables, desired_command)
385+
Kernel.exec(environment, desired_command)
380386
rescue Errno::ENOENT => e
381387
raise Error, e.message
382388
end
@@ -391,16 +397,7 @@ def dispatch(command)
391397
desc "Open a console within the environment"
392398
command def console
393399
if cmd = @config.console_command
394-
environment = @config.environment_variables
395-
puts "Starting with #{cmd.color(33)}"
396-
for key, value in environment
397-
puts " #{key.color(34)} #{value}"
398-
end
399-
begin
400-
exec(environment, cmd)
401-
rescue Errno::ENOENT => e
402-
raise Error, e.message
403-
end
400+
exec(cmd)
404401
else
405402
raise Error, "No console command has been configured in the Procfile"
406403
end

0 commit comments

Comments
 (0)