[Command Line] Added a --poll option to the compass watch subcommand to force polling.
This commit is contained in:
parent
5078d0a0a9
commit
910fc46aff
@ -5,6 +5,25 @@ require 'compass/commands/update_project'
|
|||||||
|
|
||||||
module Compass
|
module Compass
|
||||||
module Commands
|
module Commands
|
||||||
|
module WatchProjectOptionsParser
|
||||||
|
def set_options(opts)
|
||||||
|
super
|
||||||
|
|
||||||
|
opts.banner = %Q{
|
||||||
|
Usage: compass watch [path/to/project] [path/to/project/src/file.sass ...] [options]
|
||||||
|
|
||||||
|
Description:
|
||||||
|
watch the project for changes and recompile when they occur.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
}.split("\n").map{|l| l.gsub(/^ */,'')}.join("\n")
|
||||||
|
|
||||||
|
opts.on("--poll", :NONE, "Check periodically if there's been changes.") do
|
||||||
|
self.options[:poll] = 1 # check every 1 second.
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
class WatchProject < UpdateProject
|
class WatchProject < UpdateProject
|
||||||
|
|
||||||
register :watch
|
register :watch
|
||||||
@ -19,8 +38,6 @@ module Compass
|
|||||||
|
|
||||||
recompile
|
recompile
|
||||||
|
|
||||||
puts ">>> Compass is watching for changes. Press Ctrl-C to Stop."
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'fssm'
|
require 'fssm'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
@ -28,6 +45,18 @@ module Compass
|
|||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if options[:poll]
|
||||||
|
require "fssm/backends/polling"
|
||||||
|
# have to silence the ruby warning about chaning a constant.
|
||||||
|
stderr, $stderr = $stderr, StringIO.new
|
||||||
|
FSSM::Backends.const_set("Default", FSSM::Backends::Polling)
|
||||||
|
$stderr = stderr
|
||||||
|
end
|
||||||
|
|
||||||
|
action = FSSM::Backends::Default.to_s == "FSSM::Backends::Polling" ? "polling" : "watching"
|
||||||
|
|
||||||
|
puts ">>> Compass is #{action} for changes. Press Ctrl-C to Stop."
|
||||||
|
|
||||||
FSSM.monitor do |monitor|
|
FSSM.monitor do |monitor|
|
||||||
Compass.configuration.sass_load_paths.each do |load_path|
|
Compass.configuration.sass_load_paths.each do |load_path|
|
||||||
monitor.path load_path do |path|
|
monitor.path load_path do |path|
|
||||||
@ -66,6 +95,15 @@ module Compass
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def option_parser(arguments)
|
||||||
|
parser = Compass::Exec::CommandOptionParser.new(arguments)
|
||||||
|
parser.extend(Compass::Exec::GlobalOptionsParser)
|
||||||
|
parser.extend(Compass::Exec::ProjectOptionsParser)
|
||||||
|
parser.extend(CompileProjectOptionsParser)
|
||||||
|
parser.extend(WatchProjectOptionsParser)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user