8000 Skip error when running `bin/rake local` (#5789) · activeadmin/activeadmin@8eac436 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8eac436

Browse files
deivid-rodriguezjavierjulio
authored andcommitted
Skip error when running bin/rake local (#5789)
Normally, you would run `bin/rake local server`, `bin/rake local console`, or any other Rails command as the second argument. That creates a test application with seed data if it doesn't already exist, and then runs the specified Rails command on it. However, if you just run `bin/rake local`, it will generate the application but then fail with the error `bundler: exec needs a command to run`. Instead of doing that, only generate the test application and exit without error.
1 parent ff29ece commit 8eac436

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

tasks/local.rake

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ task :local do
1010
# Discard the "local" argument (name of the task)
1111
argv = ARGV[1..-1]
1212

13-
# If it's a rails command, auto add the rails script
14-
if %w(generate console server dbconsole g c s runner).include?(argv[0]) || argv[0] =~ /db:/
15-
argv.unshift('rails')
16-
end
13+
if argv.any?
14+
# If it's a rails command, auto add the rails script
15+
if %w(generate console server dbconsole g c s runner).include?(argv[0]) || argv[0] =~ /db:/
16+
argv.unshift('rails')
17+
end
1718

18-
command = ['bundle', 'exec', *argv].join(' ')
19-
gemfile = ENV['BUNDLE_GEMFILE'] || File.expand_path("../Gemfile", __dir__)
20-
env = { 'BUNDLE_GEMFILE' => gemfile }
19+
command = ['bundle', 'exec', *argv].join(' ')
20+
gemfile = ENV['BUNDLE_GEMFILE'] || File.expand_path("../Gemfile", __dir__)
21+
env = { 'BUNDLE_GEMFILE' => gemfile }
2122

22-
Dir.chdir(app_folder) do
23-
Bundler.with_original_env { Kernel.exec(env, command) }
23+
Dir.chdir(app_folder) do
24+
Bundler.with_original_env { Kernel.exec(env, command) }
25+
end
2426
end
2527
end

0 commit comments

Comments
 (0)
0