LoginSignup
5
5

More than 5 years have passed since last update.

SCSS(Sass)のコンパイルエラー時に通知する

Last updated at Posted at 2012-02-08

Sass::Plugin.on_compilation_error メソッドにブロックを渡すことで、コンパイルエラーが起きた時にブロック内を実行させることができます。
下はSassについてくるscssコマンドに、エラー処理を追記した物です。
ファイル名を scss-with-notification とでもして使うといいかな。

#!/usr/bin/env ruby

require 'sass'
require 'sass/exec'

require 'sass/plugin'
Sass::Plugin.on_compilation_error do |error, template, css|
  # Do something such like sending email or alerting to IRC and so on
  $stderr.puts "SCSS compilation error #{File.realpath(error.sass_filename)} (Line #{error.sass_line}: #{error.message})"
end

opts = Sass::Exec::Scss.new(ARGV)
opts.parse!
5
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5