diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c733b6..156136a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Master + +### Bugs fixes: + +- Pull request [#144](https://github.com/guard/guard/pull/144): Fix `guard init`. (reported by [@fabioyamate][], fixed by [@rymai][]) + ## 0.8.0 - September 28, 2011 ### Bugs fixes: @@ -266,6 +272,7 @@ [@dnagir]: https://github.com/dnagir [@docwhat]: https://github.com/docwhat [@etehtsea]: https://github.com/etehtsea +[@fabioyamate]: https://github.com/fabioyamate [@fnichol]: https://github.com/fnichol [@Gazer]: https://github.com/Gazer [@gix]: https://github.com/gix diff --git a/lib/guard/cli.rb b/lib/guard/cli.rb index 274e6bf..d8349ec 100644 --- a/lib/guard/cli.rb +++ b/lib/guard/cli.rb @@ -47,8 +47,8 @@ module Guard :banner => 'Specify a Guardfile' method_option :watch_all_modifications, - :type => :boolean, - :default => false, + :type => :boolean, + :default => false, :aliases => '-A', :banner => "Watch for all file modifications including moves and deletions" @@ -118,18 +118,17 @@ module Guard # @param [String] guard_name the name of the Guard to initialize # def init(guard_name = nil) + if !File.exist?('Guardfile') + puts 'Writing new Guardfile to #{Dir.pwd}/Guardfile' + FileUtils.cp(File.expand_path('../templates/Guardfile', __FILE__), 'Guardfile') + elsif guard_name.nil? + Guard::UI.error "Guardfile already exists at #{ Dir.pwd }/Guardfile" + exit 1 + end + if guard_name guard_class = ::Guard.get_guard_class(guard_name) guard_class.init(guard_name) - - else - if File.exist?('Guardfile') - puts 'Writing new Guardfile to #{Dir.pwd}/Guardfile' - FileUtils.cp(File.expand_path('../templates/Guardfile', __FILE__), 'Guardfile') - else - Guard::UI.error "Guardfile already exists at #{ Dir.pwd }/Guardfile" - exit 1 - end end end