From eeee5286bff15f815ead6a39365a43ef3d02e124 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 26 Apr 2019 13:20:03 +1000 Subject: [PATCH] fix: gracefully handle read only file system (eg RunKit) --- lib/pact/configuration.rb | 5 +++++ lib/pact/consumer_contract/pact_file.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/pact/configuration.rb b/lib/pact/configuration.rb index 952a475..446d292 100644 --- a/lib/pact/configuration.rb +++ b/lib/pact/configuration.rb @@ -169,6 +169,11 @@ def create_logger logger = ::Logger.new(log_path) logger.level = ::Logger::DEBUG logger + rescue Errno::EROFS + # So we can run on RunKit + logger = ::Logger.new($stdout) + logger.level = ::Logger::DEBUG + logger end end diff --git a/lib/pact/consumer_contract/pact_file.rb b/lib/pact/consumer_contract/pact_file.rb index 174f332..4288d0d 100644 --- a/lib/pact/consumer_contract/pact_file.rb +++ b/lib/pact/consumer_contract/pact_file.rb @@ -33,6 +33,8 @@ def read uri, options = {} def save_pactfile_to_tmp pact, name ::FileUtils.mkdir_p Pact.configuration.tmp_dir ::File.open(Pact.configuration.tmp_dir + "/#{name}", "w") { |file| file << pact} + rescue Errno::EROFS => e + # do nothing, probably on RunKit end def render_pact(uri_string, options)