Skip to content

Commit ab310ab

Browse files
committed
Avoid error when no examples directory exists
1 parent 33a136d commit ab310ab

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3333
- Apply "rule of three" to Client copy constructor and copy assignment operator
3434
- Run Windows tests on Windows not Ubuntu
3535
- Properly report error in building shared library
36+
- A missing `examples` directory no longer causes a crash in `cpp_library.rb`
3637

3738
### Security
3839

lib/arduino_ci/cpp_library.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ def info
135135
# @param installed_library_path [String] The library to query
136136
# @return [Array<String>] Example sketch files
137137
def example_sketches
138-
reported_dirs = info["library"]["examples"].map(&Pathname::method(:new))
138+
examples = info["library"].fetch("examples", [])
139+
reported_dirs = examples.map(&Pathname::method(:new))
139140
reported_dirs.map { |e| e + e.basename.sub_ext(".ino") }.select(&:exist?).sort_by(&:to_s)
140141
end
141142

0 commit comments

Comments
 (0)