Skip to content

Commit

Permalink
pass the gem name to Gem::Platform.match_gem?
Browse files Browse the repository at this point in the history
Although this argument isn't used in the CRuby implementation, other
implementations (specifically TruffleRuby) reserve the right to
re-implement this method with special cases for specific gems.

More context at rubygems/rubygems#3817
  • Loading branch information
flavorjones committed Oct 10, 2023
1 parent b473e19 commit a5dd494
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/tailwindcss/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Tailwindcss
module Commands
DEFAULT_DIR = File.expand_path(File.join(__dir__, "..", "..", "exe"))
GEM_NAME = "tailwindcss-rails"

# raised when the host platform is not supported by upstream tailwindcss's binary releases
class UnsupportedPlatformException < StandardError
Expand Down Expand Up @@ -34,15 +35,15 @@ def executable(exe_path: DEFAULT_DIR)
MESSAGE
end
else
if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), nil) }
if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), GEM_NAME) }
raise UnsupportedPlatformException, <<~MESSAGE
tailwindcss-rails does not support the #{platform} platform
Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation
MESSAGE
end

exe_file = Dir.glob(File.expand_path(File.join(exe_path, "*", "tailwindcss"))).find do |f|
Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), nil)
Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), GEM_NAME)
end
end

Expand Down

0 comments on commit a5dd494

Please sign in to comment.