Sha256: 99fbeaf9ba1c99cc3bcda06403eb7bb4f891f071942c53571aa574997cdab44d

Contents?: true

Size: 695 Bytes

Versions: 2

Compression:

Stored size: 695 Bytes

Contents

module Parcel
  module Rails
    class Runner
      def self.from_command_line(args)
        return from_config if args.empty?
        new(args)
      end

      def self.from_config
        to_args(::Rails.application.config.parcel)
      end

      def self.to_args(config)
        new([*config.entry_points, '-d', config.destination])
      end

      def initialize(args)
        @args = args
      end

      def compile
        parcel_commmand(:build)
      end

      def serve
        parcel_commmand
      end

      private

      def parcel_commmand(cmd = '')
        command = "yarn run parcel -- #{cmd} #{@args.join(' ')}"
        output = exec(command)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parcel-rails-0.9.1 lib/parcel/rails/runner.rb
parcel-rails-0.9.0 lib/parcel/rails/runner.rb