Rake task: Try finding a writable manpath

- OS X, Ubuntu manpath files checked
This commit is contained in:
Olle Jonsson 2016-02-25 20:13:32 +01:00
parent c111488376
commit 159173d86a

View File

@ -9,11 +9,19 @@ require "overcommit"
RuboCop::RakeTask.new RuboCop::RakeTask.new
RSpec::Core::RakeTask.new(:rspec) RSpec::Core::RakeTask.new(:rspec)
task :create_man do |_t| task :copy_man_page_to_manpath do |_t|
writable_man_path = Pathname('/etc/manpaths').each_line.find do |line| known_manpath_paths = %w(/etc/manpath.config /etc/manpaths)
manpath = known_manpath_paths.find do |f|
path = Pathname(f)
path.file? && path.readable?
end
return unless manpath
writable_man_path = Pathname(manpath).each_line.find do |line|
path = Pathname(line.chomp) path = Pathname(line.chomp)
path.directory? && path.writable? path.directory? && path.writable?
end rescue nil end
return unless writable_man_path return unless writable_man_path
@ -28,4 +36,4 @@ task :create_man do |_t|
end end
task checks: [:rubocop, :rspec] task checks: [:rubocop, :rspec]
task default: [:create_man] task default: [:copy_man_page_to_manpath]