Skip to content

Commit

Permalink
DEV: Plugin scss errors should break precompile (#6974)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmusaraj committed Feb 7, 2019
1 parent 6c19564 commit d639cad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
2 changes: 2 additions & 0 deletions lib/discourse.rb
Expand Up @@ -105,6 +105,8 @@ class CSRF < StandardError; end

class Deprecation < StandardError; end

class ScssError < StandardError; end

def self.filters
@filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks]
end
Expand Down
10 changes: 0 additions & 10 deletions lib/stylesheet/compiler.rb
Expand Up @@ -6,16 +6,6 @@ module Stylesheet

class Compiler

def self.error_as_css(error, label)
error = error.message
error.gsub!("\n", '\A ')
error.gsub!("'", '\27 ')

"#main { display: none; }
body { white-space: pre; }
body:before { font-family: monospace; content: '#{error}' }"
end

def self.compile_asset(asset, options = {})

if Importer.special_imports[asset.to_s]
Expand Down
6 changes: 1 addition & 5 deletions lib/stylesheet/manager.rb
Expand Up @@ -166,15 +166,11 @@ def compile(opts = {})
source_map_file: source_map_filename
)
rescue SassC::SyntaxError => e

# we do not need this reported as we will report it in the UI anyway
Rails.logger.info "Failed to compile #{@target} stylesheet: #{e.message}"

if %w{embedded_theme mobile_theme desktop_theme}.include?(@target.to_s)
# no special errors for theme, handled in theme editor
["", nil]
else
[Stylesheet::Compiler.error_as_css(e, "#{@target} stylesheet"), nil]
raise Discourse::ScssError, e.message
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/tasks/assets.rake
Expand Up @@ -58,7 +58,8 @@ task 'assets:precompile:css' => 'environment' do
STDERR.puts "Compiling css for #{db} #{Time.zone.now}"
begin
Stylesheet::Manager.precompile_css
rescue => PG::UndefinedColumn
rescue PG::UndefinedColumn => e
STDERR.puts "#{e.class} #{e.message}: #{e.backtrace.join("\n")}"
STDERR.puts "Skipping precompilation of CSS cause schema is old, you are precompiling prior to running migrations."
end
end
Expand Down

0 comments on commit d639cad

Please sign in to comment.