From d1c2f765a6615835067d0f4109f598471dbfdcc9 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Tue, 26 Jan 2021 10:27:58 -0500 Subject: [PATCH 1/2] Wrap file creation in try/catch --- CHANGELOG.md | 3 +++ lib/codecov/formatter.rb | 11 ++++++----- lib/codecov/version.rb | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75f5e33..fa53162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### `0.4.2` +- # Wrap file creation in try/catch + ### `0.4.1` - #133 Write down to file when using the formatter diff --git a/lib/codecov/formatter.rb b/lib/codecov/formatter.rb index 25689ed..c4c5c0b 100644 --- a/lib/codecov/formatter.rb +++ b/lib/codecov/formatter.rb @@ -17,12 +17,13 @@ def format(report) } result.update(result_to_codecov(report)) - result_path = File.join(::SimpleCov.coverage_path, RESULT_FILE_NAME) - if File.writable?(result_path) + begin + result_path = File.join(::SimpleCov.coverage_path, RESULT_FILE_NAME) File.write(result_path, result['codecov']) - puts "Coverage report generated to #{result_path}.\#{result}" - else - puts "Could not write coverage report to file #{result_path}.\n#{result}" + puts "Coverage report generated to #{result_path}.\n#{result}" + rescue Errno::ENOENT => e + puts e + puts "Could not write coverage report to file.\n#{result}" end result diff --git a/lib/codecov/version.rb b/lib/codecov/version.rb index 63acaac..f9f0fb2 100644 --- a/lib/codecov/version.rb +++ b/lib/codecov/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Codecov - VERSION = '0.4.1' + VERSION = '0.4.2' end From 991a1e4f37440dd87c760640d40d2ace24c9ea91 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Tue, 26 Jan 2021 10:28:38 -0500 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa53162..089049f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ### `0.4.2` -- # Wrap file creation in try/catch +- #134 Wrap file creation in try/catch ### `0.4.1` - #133 Write down to file when using the formatter