...
 
Commits (2)
......@@ -137,12 +137,17 @@ end
desc 'Run the lighthouse tool against evaryont.me or environment variable $url'
task :lighthouse do
unless which('lighthouse')
puts "ERROR: lighthouse CLI tool not installed. Run `npm i -g lighthouse` and update $PATH!"
next
end
url = ENV['url'] || 'https://evaryont.me'
launch_chrome
ENV['LIGHTHOUSE_CHROMIUM_PATH'] = "/usr/bin/chromium"
sh "lighthouse --quiet --view --output-path=./lighthouse-results.html --port=#{chromium_port} #{url}"
sh "lighthouse --quiet --view --output-path=./lighthouse-results.html --port=#{chromium_port} --no-enable-error-reporting #{url}"
end
task :resume2 do
......
......@@ -27,5 +27,17 @@ module EvaryontsHelpers
}
end
# https://stackoverflow.com/a/5471032
def which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each { |ext|
exe = File.join(path, "#{cmd}#{ext}")
return exe if File.executable?(exe) && !File.directory?(exe)
}
end
return nil
end
end
end