From cb0b02c91889fec0e76800b09db901ede0dbe412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szikszai=20Guszt=C3=A1v?= Date: Thu, 17 Aug 2017 10:41:41 +0200 Subject: [PATCH] Skip versions that are partial semvers (0.1) and the ones that don't have proper elm-package.json persent. Fixes: #37 --- lib/elm_install/identifier.rb | 17 +++++++---------- lib/elm_install/repository.rb | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/elm_install/identifier.rb b/lib/elm_install/identifier.rb index 819c2ee..cca93a2 100644 --- a/lib/elm_install/identifier.rb +++ b/lib/elm_install/identifier.rb @@ -133,23 +133,20 @@ def json(directory) path = File.join(directory, 'elm-package.json') JSON.parse(File.read(path)) rescue JSON::ParserError - exit "Invalid JSON in file: #{path.bold}" - {} + warn "Invalid JSON in file: #{path.bold}" rescue Errno::ENOENT - exit "Could not find file: #{path.bold}" - {} + warn "Could not find file: #{path.bold}" end - Contract String => NilClass + Contract String => Hash # Exits the current process and logs a given message. # # @param message [String] The message # - # @return nil - def exit(message) - Logger.arrow message - Process.abort - nil + # @return [Hash] An empty hash + def warn(message) + Logger.arrow message if @options[:vebose] + {} end end end diff --git a/lib/elm_install/repository.rb b/lib/elm_install/repository.rb index 96d06f8..36f0272 100644 --- a/lib/elm_install/repository.rb +++ b/lib/elm_install/repository.rb @@ -54,6 +54,7 @@ def versions repo .tags .map(&:name) + .select { |tag| tag =~ /(.*\..*\..*)/ } .map { |tag| Semverse::Version.try_new tag } .compact end