Fixes #144, due to a too-hardore refactoring! ;)

We will need specs for Guard::CLI!
This commit is contained in:
Rémy Coutable 2011-09-29 00:27:19 +02:00
parent 243ea157a9
commit 1607901e43
2 changed files with 17 additions and 11 deletions

View File

@ -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 ## 0.8.0 - September 28, 2011
### Bugs fixes: ### Bugs fixes:
@ -266,6 +272,7 @@
[@dnagir]: https://github.com/dnagir [@dnagir]: https://github.com/dnagir
[@docwhat]: https://github.com/docwhat [@docwhat]: https://github.com/docwhat
[@etehtsea]: https://github.com/etehtsea [@etehtsea]: https://github.com/etehtsea
[@fabioyamate]: https://github.com/fabioyamate
[@fnichol]: https://github.com/fnichol [@fnichol]: https://github.com/fnichol
[@Gazer]: https://github.com/Gazer [@Gazer]: https://github.com/Gazer
[@gix]: https://github.com/gix [@gix]: https://github.com/gix

View File

@ -118,18 +118,17 @@ module Guard
# @param [String] guard_name the name of the Guard to initialize # @param [String] guard_name the name of the Guard to initialize
# #
def init(guard_name = nil) def init(guard_name = nil)
if guard_name if !File.exist?('Guardfile')
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' puts 'Writing new Guardfile to #{Dir.pwd}/Guardfile'
FileUtils.cp(File.expand_path('../templates/Guardfile', __FILE__), 'Guardfile') FileUtils.cp(File.expand_path('../templates/Guardfile', __FILE__), 'Guardfile')
else elsif guard_name.nil?
Guard::UI.error "Guardfile already exists at #{ Dir.pwd }/Guardfile" Guard::UI.error "Guardfile already exists at #{ Dir.pwd }/Guardfile"
exit 1 exit 1
end end
if guard_name
guard_class = ::Guard.get_guard_class(guard_name)
guard_class.init(guard_name)
end end
end end