mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge pull request #1867 from capistrano/allow-cap-t-without-capfile
Allow `cap -T` to run without Capfile present
This commit is contained in:
commit
77481802b9
5 changed files with 24 additions and 8 deletions
|
@ -13,6 +13,7 @@ gem "capistrano", :github => "capistrano/capistrano"
|
|||
https://github.com/capistrano/capistrano/compare/v3.7.2...HEAD
|
||||
|
||||
* Your contribution here!
|
||||
* [#1867](https://github.com/capistrano/capistrano/pull/1867): Allow `cap -T` to run without Capfile present - [@mattbrictson](https://github.com/mattbrictson)
|
||||
|
||||
## `3.8.0` (2017-03-10)
|
||||
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
Feature: Installation
|
||||
|
||||
Background:
|
||||
Given a test app with the default configuration
|
||||
Given a test app without any configuration
|
||||
|
||||
Scenario: The "install" task documentation can be viewed
|
||||
When I run "cap -T"
|
||||
Then the task is successful
|
||||
And contains "cap install" in the output
|
||||
|
||||
Scenario: With default stages
|
||||
When I run cap "install"
|
||||
When I run "cap install"
|
||||
Then the deploy.rb file is created
|
||||
And the default stage files are created
|
||||
And the tasks folder is created
|
||||
|
||||
Scenario: With specified stages
|
||||
When I run cap "install STAGES=qa,production"
|
||||
When I run "cap install STAGES=qa,production"
|
||||
Then the deploy.rb file is created
|
||||
And the specified stage files are created
|
||||
And the tasks folder is created
|
||||
|
|
|
@ -2,6 +2,10 @@ Given(/^a test app with the default configuration$/) do
|
|||
TestApp.install
|
||||
end
|
||||
|
||||
Given(/^a test app without any configuration$/) do
|
||||
TestApp.create_test_app
|
||||
end
|
||||
|
||||
Given(/^servers with the roles app and web$/) do
|
||||
begin
|
||||
vagrant_cli_command("up")
|
||||
|
|
|
@ -96,7 +96,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
def load_imports
|
||||
if options.show_tasks
|
||||
if options.show_tasks && Rake::Task.task_defined?("load:defaults")
|
||||
invoke "load:defaults"
|
||||
set(:stage, "")
|
||||
Dir[deploy_config_path].each { |f| add_import f }
|
||||
|
|
|
@ -44,14 +44,14 @@ module TestApp
|
|||
end
|
||||
|
||||
Dir.chdir(test_app_path) do
|
||||
`bundle`
|
||||
run "bundle"
|
||||
end
|
||||
end
|
||||
|
||||
def install_test_app_with(config)
|
||||
create_test_app
|
||||
Dir.chdir(test_app_path) do
|
||||
`bundle exec cap install STAGES=#{stage}`
|
||||
run "cap install STAGES=#{stage}"
|
||||
end
|
||||
write_local_deploy_file(config)
|
||||
end
|
||||
|
@ -91,14 +91,15 @@ module TestApp
|
|||
end
|
||||
|
||||
def cap(task, subdirectory=nil)
|
||||
run "bundle exec cap #{stage} #{task}", subdirectory
|
||||
run "cap #{stage} #{task} --trace", subdirectory
|
||||
end
|
||||
|
||||
def run(command, subdirectory=nil)
|
||||
output = nil
|
||||
command = "bundle exec #{command}" unless command =~ /^bundle\b/
|
||||
dir = subdirectory ? test_app_path.join(subdirectory) : test_app_path
|
||||
Dir.chdir(dir) do
|
||||
output = `#{command}`
|
||||
output = with_clean_bundler_env { `#{command}` }
|
||||
end
|
||||
[$CHILD_STATUS.success?, output]
|
||||
end
|
||||
|
@ -187,4 +188,9 @@ module TestApp
|
|||
def git_wrapper_path
|
||||
"/tmp/git-ssh-my_app_name-#{stage}-#{current_user}.sh"
|
||||
end
|
||||
|
||||
def with_clean_bundler_env(&block)
|
||||
return yield unless defined?(Bundler)
|
||||
Bundler.with_clean_env(&block)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue