Sha256: 0ffaadb712d992c4185cdb457117431e5e72a50d33547ad4ef50a0b1376232f3

Contents?: true

Size: 891 Bytes

Versions: 3

Compression:

Stored size: 891 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|
            Svgeez::Commands::Build.process(options)
            Svgeez::Commands::Watch.process(options)
          end
        end
      end

      def self.process(options)
        sprite_builder = Svgeez::SpriteBuilder.new(options)

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
svgeez-1.0.2 lib/svgeez/commands/watch.rb
svgeez-1.0.1 lib/svgeez/commands/watch.rb
svgeez-1.0.0 lib/svgeez/commands/watch.rb