Rake task: Try finding a writable manpath
- OS X, Ubuntu manpath files checked
This commit is contained in:
parent
85d5352e6e
commit
32f14e685b
16
Rakefile
16
Rakefile
|
@ -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]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user