Commit 28ccd220 authored by Evaryont's avatar Evaryont

Add a which lighthouse check to the rake task

parent 0bb0781f
Pipeline #21 failed with stage
in 2 minutes
......@@ -137,6 +137,11 @@ 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
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment