Sha256: b673261a59380f9153a9cf8abfb0ef4897d396852b7ad5c66dc2f0336200f6a4

Contents?: true

Size: 904 Bytes

Versions: 6

Compression:

Stored size: 904 Bytes

Contents

module Svgeez
  module Commands
    class Watch < Command
      class << self
        def 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 process(options)
          Svgeez.logger.info %{Watching `#{File.expand_path(options['source'])}` for changes... Press ctrl-c to stop.}

          listener = Listen.to(options['source'], only: /\.svg$/) do |modified, added, removed|
            Svgeez::Commands::Build.process(options)
          end

          listener.start
          sleep
        rescue Interrupt => e
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
svgeez-0.2.0 lib/svgeez/commands/watch.rb
svgeez-0.1.4 lib/svgeez/commands/watch.rb
svgeez-0.1.3 lib/svgeez/commands/watch.rb
svgeez-0.1.2 lib/svgeez/commands/watch.rb
svgeez-0.1.1 lib/svgeez/commands/watch.rb
svgeez-0.1.0 lib/svgeez/commands/watch.rb