Sha256: 54334edc1ef09596de80e34f37345317a4aa3bf17123fa6ae3dc96b4eefcd380

Contents?: true

Size: 1.88 KB

Versions: 5

Compression:

Stored size: 1.88 KB

Contents

module MagLove
  module Command
    class Util
      include Commander::Methods
      
      def run
        
        task :cache_clear, bucket: "cdn.magloft.com" do |args, options|
          debug("▸ clearing cache for #{options.bucket}.magloft.com")
          system "gsutil -m setmeta -R -h 'Cache-Control:public, max-age=0, no-transform' gs://#{options.bucket}.magloft.com/themes"
        end
        
        task :browser_sync, theme: "!", files: "!", port: "3002", proxy_port: "3001", host: "localhost", start_path: "/", log_level: "silent" do |args, options|
          debug("▸ starting browser-sync")
          job = fork do
            begin
              system "browser-sync start --proxy #{options.host}:#{options.proxy_port} --port #{options.port} --files '#{options.files}' --startPath '#{options.start_path}' --logLevel #{options.log_level} --no-ui"
            rescue Exception => e
              info("▸ shutting down browser sync")
            end
          end
          Process.detach(job)
        end
        
        task :watch, theme: "!", block: "NO" do |args, options|
          info("▸ watching theme #{options.theme}")
          watch_config({
            "compile:coffee" => [theme_path("**/*.{coffee,js}", options.theme), theme_base_path("**/*.{coffee,js}", options.theme)],
            "compile:css" => [theme_path("**/*.{less,scss,css}", options.theme), theme_base_path("**/*.{less,scss,css}", options.theme)],
            "compile:templates" => [theme_path("**/*.{haml,twig,html}", options.theme)],
            "copy:base_images" => theme_base_path("images/**/*.{jpg,jpeg,gif,png,svg}", options.theme),
            "copy:images" => theme_path("images/**/*.{jpg,jpeg,gif,png,svg}", options.theme)
          }, options)
          
          if options.block == "YES"
            while true
              sleep 100
            end
          end
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
maglove-0.8.1 lib/maglove/command/util.rb
maglove-0.8.0 lib/maglove/command/util.rb
maglove-0.7.2 lib/maglove/command/util.rb
maglove-0.7.1 lib/maglove/command/util.rb
maglove-0.7.0 lib/maglove/command/util.rb