class Guard::Sasslint
Constants
- RAKETASK
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
# File lib/guard/sasslint.rb, line 9 def initialize(options = {}) enforce_js_dependencies! @config = options.fetch(:config, nil) @run_at_start = options.fetch(:run_at_start, false) load 'Rakefile' super options end
Public Instance Methods
run_all()
click to toggle source
# File lib/guard/sasslint.rb, line 24 def run_all UI.info 'sasslint ⇒ all sass' lint end
run_on_changes(paths)
click to toggle source
# File lib/guard/sasslint.rb, line 29 def run_on_changes(paths) paths.each { |path| lint path } end
start()
click to toggle source
# File lib/guard/sasslint.rb, line 19 def start UI.info 'sasslint starting...' run_all if @run_at_start end
Private Instance Methods
enforce_js_dependencies!()
click to toggle source
# File lib/guard/sasslint.rb, line 40 def enforce_js_dependencies! if !find_dependency 'yarnpkg' UI.error 'Unable to locate the yarnpkg library' UI.error 'To install yarn visit: https://yarnpkg.com/en/docs/install' exit 1 end if !find_dependency 'node' UI.error 'Unable to locate the node binary' UI.error 'Depending on OS and install method used you may need to symlink node to nodejs' exit 1 end end
find_dependency(executable)
click to toggle source
this hacky workaround prevents mkmf from polluting the project with mkmf.log files
# File lib/guard/sasslint.rb, line 56 def find_dependency(executable) old_mkmf_log = MakeMakefile::Logging.instance_variable_get(:@logfile) set_mkmf_log(nil) path_to_cmd = find_executable0(executable) set_mkmf_log(old_mkmf_log) path_to_cmd end
lint(file = nil)
click to toggle source
# File lib/guard/sasslint.rb, line 35 def lint(file = nil) ::Rake::Task[RAKETASK].reenable ::Rake::Task[RAKETASK].invoke(file, @config) end
set_mkmf_log(logfile = File::NULL)
click to toggle source
# File lib/guard/sasslint.rb, line 65 def set_mkmf_log(logfile = File::NULL) MakeMakefile::Logging.instance_variable_set(:@logfile, logfile) end