Sha256: 2b52682dfe4f941aaf7671023d535f1c077f4215af23a4f0c0983718281695a1

Contents?: true

Size: 872 Bytes

Versions: 4

Compression:

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

          listener.start
          sleep
        rescue Interrupt
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
svgeez-0.2.4 lib/svgeez/commands/watch.rb
svgeez-0.2.3 lib/svgeez/commands/watch.rb
svgeez-0.2.2 lib/svgeez/commands/watch.rb
svgeez-0.2.1 lib/svgeez/commands/watch.rb