Permalink
Browse files

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

We will need specs for Guard::CLI!
  • Loading branch information...
1 parent 243ea15 commit 1607901e431a073a09f36327038e5d391cf1bfdb Rémy Coutable committed Sep 28, 2011
Showing with 17 additions and 11 deletions.
  1. +7 −0 CHANGELOG.md
  2. +10 −11 lib/guard/cli.rb
View
@@ -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
View
@@ -47,8 +47,8 @@ class CLI < Thor
: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 @@ def version
# @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

0 comments on commit 1607901

Please sign in to comment.