Allow `cap -T` to work when no Capfile is present

Previously, the `cap -T` command assumed the presence of the
`load:defaults` task. This task is only present if a proper Capfile is
loaded, and so `cap -T` wouldn't work in a new, not yet "capified"
project.

This commit fixes the bug by testing that `load:defaults` is defined
before calling it.
This commit is contained in:
Matt Brictson 2017-03-19 20:02:38 -07:00
parent 84407c63a7
commit 27a8fbe8ef
No known key found for this signature in database
GPG Key ID: 2F279EAD1F2ACFAF
3 changed files with 7 additions and 1 deletions

View File

@ -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)

View File

@ -3,6 +3,11 @@ Feature: Installation
Background:
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"
Then the deploy.rb file is created

View File

@ -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 }