#!/usr/bin/ruby
# because rubygems shims assume a gem's executables are Ruby

require "tailwindcss/ruby"

begin
  command = [Tailwindcss::Ruby.executable, *ARGV]
  puts command.inspect
  if Gem.win_platform?
    # use system rather than exec as exec inexplicably fails to find the executable on Windows
    # see related https://github.com/rubys/sprockets-esbuild/pull/4
    system(*command, exception: true)
  else
    exec(*command)
  end
rescue Tailwindcss::Ruby::UnsupportedPlatformException, Tailwindcss::Ruby::ExecutableNotFoundException => e
  STDERR.puts("ERROR: " + e.message)
  exit 1
end
