lib/awestruct/cli/auto.rb in awestruct-0.5.6.beta8 vs lib/awestruct/cli/auto.rb in awestruct-0.5.6.beta9
- old
+ new
@@ -16,16 +16,22 @@
def run()
generate_thread = nil
current_path = nil
- guard = if ( @config.options.livereload )
- guard = Guard::LiveReload.new
- guard.start
- guard
- else
- nil
+ begin
+ guard = if ( @config.options.livereload )
+ Guard.init({})
+ guard = Guard::LiveReload.new
+ guard.start
+ guard
+ else
+ nil
+ end
+ rescue => e
+ puts e
+ puts e.backtrace
end
force_polling = ( RUBY_PLATFORM =~ /mingw/ ? true : false )
listener = Listen.to( @config.dir, :latency=>0.5, :force_polling=>force_polling ) do |modified, added, removed|
modified.each do |path| # path is absolute path
@@ -43,29 +49,27 @@
current_path = path
end
generate_thread = Thread.new {
begin
- if ( File.extname(path) == '.sass' || File.extname(path) == '.scss' )
- # TODO use sass here, eventually, as soon as I can figure out how to get it and sprites to work
- ::Compass::Commands::UpdateProject.new(engine.site.dir, {}).perform
- # fixes the nil later on, there's an outstanding bug that css
- # pages aren't output in the correct directory
- pages = []
- else
- page = engine.page_by_source_path(path)
- pages = []
- if ( page )
+ page = engine.page_by_source_path(path)
+ pages = []
+ if ( page )
+ unless ( guard )
pages = engine.generate_page_and_dependencies( page )
else
- if File.exist? path
- # chances are this is an extension or yaml file
- pages = engine.run_auto_for_non_page(path)
- end
+ pages = engine.page_dependencies( page )
end
+ else
+ if File.exist? path
+ # chances are this is an extension or yaml file
+ pages = engine.run_auto_for_non_page(path, !@config.options.generate_on_access)
+ end
end
- $LOG.info "Regeneration finished." if $LOG.info?
+ unless ( guard )
+ $LOG.info "Regeneration finished." if $LOG.info?
+ end
if ( guard )
urls = pages.map do |p|
@base_url + p.url.to_s
end