Skip to content

Commit

Permalink
Clean up more thoroughly after running MR
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines committed Jan 28, 2021
1 parent 8de4f25 commit a4dc396
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@

# Copy bugsnag-laravel into fixture directories
FIXTURE_DIR = 'features/fixtures'
VENDORED_LIB = FIXTURE_DIR + '/bugsnag-laravel.zip'
VENDORED_LIB = "#{FIXTURE_DIR}/bugsnag-laravel.zip"
FILES_TO_CLEANUP = [VENDORED_LIB]

`composer archive -f zip --dir=#{File.dirname(VENDORED_LIB)} --file=#{File.basename(VENDORED_LIB, '.zip')}`

Dir.glob(FIXTURE_DIR + '/laravel*').each do |directory|
next if directory.end_with?('laravel-latest')

FileUtils.cp(VENDORED_LIB, directory + '/bugsnag-laravel.zip')
zip = "#{directory}/bugsnag-laravel.zip"
FILES_TO_CLEANUP << zip

FileUtils.cp(VENDORED_LIB, zip)

# Remove any locally installed composer deps
FileUtils.rm_rf(directory + '/vendor')
FileUtils.rm_rf("#{directory}/vendor")
end


# Copy current requirements into fixture requirements
File.open('composer.json', 'r') do |source|
parsed_composer = JSON.parse(source.read)
Expand All @@ -27,7 +32,10 @@
parsed_template = JSON.parse template.read
parsed_template["repositories"][0]["package"]["require"] = requirements

File.open(directory + '/composer.json', 'w') do |target|
composer_json = "#{directory}/composer.json"
FILES_TO_CLEANUP << composer_json

File.open(composer_json, 'w') do |target|
target.write(JSON.pretty_generate(parsed_template))
end
end
Expand All @@ -41,7 +49,9 @@
end

at_exit do
FileUtils.rm_rf(VENDORED_LIB)
FILES_TO_CLEANUP.each do |file|
FileUtils.rm_rf(file)
end
end

AfterConfiguration do |_config|
Expand Down

0 comments on commit a4dc396

Please sign in to comment.