webpacker.rake 839 B

12345678910111213141516171819202122232425262728293031323334
  1. # frozen_string_literal: true
  2. # Disable this task as we use pnpm
  3. require 'semantic_range'
  4. Rake::Task['webpacker:check_yarn'].clear
  5. namespace :webpacker do
  6. desc 'Verifies if Yarn is installed'
  7. task check_yarn: :environment do
  8. begin
  9. yarn_version = `yarn --version`.strip
  10. raise Errno::ENOENT if yarn_version.blank?
  11. yarn_range = '>=4 <5'
  12. is_valid = begin
  13. SemanticRange.satisfies?(yarn_version, yarn_range)
  14. rescue
  15. false
  16. end
  17. unless is_valid
  18. warn "Mastodon and Webpacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
  19. warn 'Exiting!'
  20. exit!
  21. end
  22. rescue Errno::ENOENT
  23. warn 'Yarn not installed. Please see the Mastodon documentation to install the correct version.'
  24. warn 'Exiting!'
  25. exit!
  26. end
  27. end
  28. end