Sha256: de9822437bbac48873432b71bcbefa15d297058d5c4cb781e59de6038c997af3

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

require "shellwords"
require_relative "../command"
require_relative "../../../system_call"

module Hanami
  module CLI
    module Commands
      module App
        module Assets
          # @since 2.1.0
          # @api private
          class Command < App::Command
            def initialize(config: app.config.assets, system_call: SystemCall.new, **)
              super()
              @system_call = system_call
              @config = config
            end

            # @since 2.1.0
            # @api private
            def call(**)
              cmd, *args = cmd_with_args

              system_call.call(cmd, *args)
            end

            private

            # @since 2.1.0
            # @api private
            attr_reader :config

            # @since 2.1.0
            # @api private
            attr_reader :system_call

            # @since 2.1.0
            # @api private
            def cmd_with_args
              [config.package_manager_run_command, "assets"]
            end

            # @since 2.1.0
            # @api private
            def entry_points
              config.entry_points.map do |entry_point|
                escape(entry_point)
              end.join(" ")
            end

            # @since 2.1.0
            # @api private
            def destination
              escape(config.destination)
            end

            # @since 2.1.0
            # @api private
            def escape(str)
              Shellwords.shellescape(str)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-cli-2.1.0.rc1 lib/hanami/cli/commands/app/assets/command.rb