From a4dc3960b85b2cb0f6426eadfae70d1610c8b36d Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 28 Jan 2021 15:48:17 +0000 Subject: [PATCH] Clean up more thoroughly after running MR --- features/support/env.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/features/support/env.rb b/features/support/env.rb index a39311dc..ac9e40f8 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -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) @@ -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 @@ -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|