Sha256: 3e6b7b9c9583b37e77884431c85002aee7fa347cbf59a93d65a244d9e460ca1a

Contents?: true

Size: 845 Bytes

Versions: 1

Compression:

Stored size: 845 Bytes

Contents

module Svgeez
  module Commands
    class Watch < Command
      def self.init_with_program(p)
        p.command(:watch) do |c|
          c.description 'Watches a folder of SVG icons for changes'
          c.syntax 'watch [options]'

          add_build_options(c)

          c.action do |_, options|
            Build.process(options)
            Watch.process(options)
          end
        end
      end

      def self.process(options)
        builder = Svgeez::Builder.new(options)

        listener = Listen.to(builder.source.folder_path, only: /\.svg\z/) do
          builder.build
        end

        Svgeez.logger.info "Watching `#{builder.source.folder_path}` for changes... Press ctrl-c to stop."

        listener.start
        sleep
      rescue Interrupt
        Svgeez.logger.info 'Quitting svgeez...'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
svgeez-1.0.3 lib/svgeez/commands/watch.rb