Permalink
Browse files

make some gem-release commands not trample existing files

  • Loading branch information...
1 parent af674bd commit 8e494ae7652c1e4e8c9607a777d372181d00f20e flooose committed with Sven Fuchs Oct 27, 2010
@@ -23,6 +23,10 @@ def files
end
end
+ def exists?
+ File.exists?(filename)
+ end
+
def filename
"#{name}.gemspec"
end
@@ -38,12 +38,19 @@ def write_scaffold
def write_version
version = Version.new(options)
- say "Creating #{version.filename}"
- version.write
+ if File.exists?("#{version.filename}")
+ say "Skipping #{version.filename}: already exists"
+ else
+ say "Creating #{version.filename}"
+ version.write
+ end
end
def write_rakefile
- rakefile = <<RAKEFILE
+ if File.exists?('Rakefile')
+ say "Skipping Rakefile: already exists"
+ else
+ rakefile = <<RAKEFILE
require 'rake'
require 'rake/testtask'
@@ -55,7 +62,8 @@ def write_rakefile
task :default => :test
RAKEFILE
- File.open('Rakefile', 'w').write(rakefile)
+ File.open('Rakefile', 'w').write(rakefile)
+ end
end
def create_repo
@@ -14,7 +14,11 @@ def initialize
def execute
gemspec = Gemspec.new(options)
- say "Creating #{gemspec.filename}"
- gemspec.write
+ if gemspec.exists?
+ say "Skipping #{gemspec.filename}: already exists"
+ else
+ say "Creating #{gemspec.filename}"
+ gemspec.write
+ end
end
end

0 comments on commit 8e494ae

Please sign in to comment.