From 27a8fbe8efe2fb3970574eb016f731e2017365be Mon Sep 17 00:00:00 2001 From: Matt Brictson Date: Sun, 19 Mar 2017 20:02:38 -0700 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + features/installation.feature | 5 +++++ lib/capistrano/application.rb | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff399936..70350769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/features/installation.feature b/features/installation.feature index 60fca09c..47574262 100644 --- a/features/installation.feature +++ b/features/installation.feature @@ -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 diff --git a/lib/capistrano/application.rb b/lib/capistrano/application.rb index d1423e14..101a6090 100644 --- a/lib/capistrano/application.rb +++ b/lib/capistrano/application.rb @@ -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 }