Sha256: 26a315b5f758804a26d604a34b05878c237fa8935405d08d0e7046e589816e9f

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require "semantic_range"

namespace :webpacker do
  desc "Verifies if pnpm is installed"
  task check_pnpm: [:environment] do
    begin
      $stdout.puts "Verifying pnpm version..."

      pnpm_version = `pnpm --version`.chomp
      raise Errno::ENOENT if pnpm_version.blank?

      begin
        pnpm_range = ">= 3.0.0"
        is_unsupported = SemanticRange.satisfies?(pnpm_version, pnpm_range)
      rescue StandardError
        is_unsupported = false
      end

      unless is_unsupported
        warn(
          <<~HEREDOC.squish
            Webpacker requires pnpm \"#{pnpm_range}\" and you are using #{pnpm_version}.
            Please upgrade pnpm https://pnpm.js.org/en/installation/.
          HEREDOC
        )
        warn("Exiting!")
        exit!
      end
    rescue Errno::ENOENT
      warn(
        <<~HEREDOC.squish
          pnpm is not installed. Please download and install pnpm from
          https://pnpm.js.org/en/installation/.
        HEREDOC
      )
      warn("Exiting!")
      exit!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webpacker-pnpm-1.2.1 lib/webpacker/tasks/check_pnpm.rake