# typed: strict
# frozen_string_literal: true

module OS
  module Mac
    module Cask
      module Installer
        extend T::Helpers

        requires_ancestor { ::Cask::Installer }

        sig { void }
        def check_stanza_os_requirements
          return if !cask.depends_on.requires_linux? && artifacts.all? { |artifact| supported_artifact?(artifact) }

          raise ::Cask::CaskError, "#{cask}: This cask requires Linux."
        end

        private

        sig { params(artifact: ::Cask::Artifact::AbstractArtifact).returns(T::Boolean) }
        def supported_artifact?(artifact)
          ::Cask::Artifact::LINUX_ONLY_ARTIFACTS.exclude?(artifact.class)
        end
      end
    end
  end
end

Cask::Installer.prepend(OS::Mac::Cask::Installer)
