Skip to content

Commit

Permalink
Enhance ecosystems rake task to detect changes and restart with updat…
Browse files Browse the repository at this point in the history
…ed code
  • Loading branch information
andrew committed Feb 17, 2025
1 parent d5171dc commit a2d69e4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/tasks/ecosystems.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ namespace :ecosystems do
shared_asset_repo = "https://github.com/ecosyste-ms/advisories"
branch = "main"
temp_dir = "tmp/ecosystems_assets"
ecosystems_rake_path = "lib/tasks/ecosystems.rake"
temp_rake_file = "#{temp_dir}/lib/tasks/ecosystems.rake"

# Ensure temp directory is clean
`rm -rf #{temp_dir}`
Expand All @@ -18,7 +20,20 @@ namespace :ecosystems do
`mkdir -p app/assets/images`
`mkdir -p public`

# Check if ecosystems.rake has changed
if !FileUtils.compare_file(temp_rake_file, ecosystems_rake_path)
puts "ecosystems.rake has changed, restarting task with new code..."
`cp #{temp_rake_file} #{ecosystems_rake_path}`

# Cleanup
`rm -rf #{temp_dir}`

# Re-execute the current Rake task using exec to replace the running process
exec("rake ecosystems:update_shared_assets")
end

# Copy required files
`cp #{temp_rake_file} #{ecosystems_rake_path}`
`cp #{temp_dir}/app/views/shared/_header.html.erb app/views/shared/`
`cp #{temp_dir}/app/views/shared/_footer.html.erb app/views/shared/`
`cp #{temp_dir}/app/views/shared/_menu.html.erb app/views/shared/`
Expand All @@ -32,4 +47,4 @@ namespace :ecosystems do

puts "Shared assets updated successfully."
end
end
end

0 comments on commit a2d69e4

Please sign in to comment.