Skip to content

Commit 2a07090

Browse files
zkoppertCopilot
andcommitted
Fail loudly if VERSION cannot be read from lib
Previously the gemspec dereferenced MatchData#[] directly, so a formatting change in lib/github-markup.rb that broke the regex would raise NoMethodError on nil. Wrap the match in an explicit check and raise with the file path so the failure is obvious. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Zack Koppert <zkoppert@github.com>
1 parent 05d38d8 commit 2a07090

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

github-markup.gemspec

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
version = File.read(File.expand_path("../lib/github-markup.rb", __FILE__))
2-
.match(/VERSION = ['"]([^'"]+)['"]/)[1]
1+
version_file = File.expand_path("../lib/github-markup.rb", __FILE__)
2+
version_match = File.read(version_file).match(/VERSION = ['"]([^'"]+)['"]/)
3+
raise "Could not find VERSION in #{version_file}" unless version_match
4+
version = version_match[1]
35

46
Gem::Specification.new do |s|
57
s.name = "github-markup"

0 commit comments

Comments
 (0)