Skip to content

Commit

Permalink
Merge pull request #71 from theSteveMitchell/origin/duplicate_names
Browse files Browse the repository at this point in the history
Origin/duplicate names
  • Loading branch information
theSteveMitchell authored Dec 1, 2024
2 parents 6975187 + f8f3a44 commit 2baa09f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/generators/task/task_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module AfterParty
module Generators
# creates after_party tasks
class TaskGenerator < Rails::Generators::Base
FILE_MASK = File.join(Rails.root, 'lib/tasks/deployment/*.rake')
source_root(File.expand_path('templates', __dir__))
argument(:name, type: :string)
class_option(
Expand All @@ -15,10 +16,15 @@ class TaskGenerator < Rails::Generators::Base
)

def copy_deploy_task
template(
'deploy.txt.erb',
"lib/tasks/deployment/#{timestamp}_#{file_name}.rake"
)
file_names = Dir[FILE_MASK].collect { |f| AfterParty::TaskRecorder.new(f) }.map { |f| f.task_name.to_s }
if file_names.include?(file_name)
puts 'Error: Please Create a unique task name'
else
template(
'deploy.txt.erb',
"lib/tasks/deployment/#{timestamp}_#{file_name}.rake"
)
end
end

private
Expand Down

0 comments on commit 2baa09f

Please sign in to comment.