Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Wrap file creation in try/catch (#134)
Browse files Browse the repository at this point in the history
* Wrap file creation in try/catch

* Update CHANGELOG
  • Loading branch information
thomasrockhu committed Jan 27, 2021
1 parent 9700fbe commit b04f1d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### `0.4.2`
- #134 Wrap file creation in try/catch

### `0.4.1`
- #133 Write down to file when using the formatter

Expand Down
11 changes: 6 additions & 5 deletions lib/codecov/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

This comment has been minimized.

Copy link
@RomanVanLoo

RomanVanLoo Feb 3, 2021

Why do you want to print out the whole result hash when writing the report was successful generated? Wouldn't it be better to only print it when the Errno::ENOENT is triggered?

This comment has been minimized.

Copy link
@thomasrockhu

thomasrockhu Feb 3, 2021

Author Contributor

@RomanVanLoo addressing here

This comment has been minimized.

Copy link
@RomanVanLoo

RomanVanLoo Feb 3, 2021

Perfect, thank sir!

rescue Errno::ENOENT => e
puts e
puts "Could not write coverage report to file.\n#{result}"
end

result
Expand Down
2 changes: 1 addition & 1 deletion lib/codecov/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Codecov
VERSION = '0.4.1'
VERSION = '0.4.2'
end

0 comments on commit b04f1d1

Please sign in to comment.