Skip to content

Commit

Permalink
Merge pull request #34 from deivid-rodriguez/lazily_require_etc
Browse files Browse the repository at this point in the history
Lazily require `etc`
  • Loading branch information
hsbt committed Mar 27, 2019
2 parents 9e925fa + c8f9c1e commit 5814e3b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/fileutils.rb
Expand Up @@ -1081,11 +1081,6 @@ def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
end
module_function :chown_R

begin
require 'etc'
rescue LoadError # rescue LoadError for miniruby
end

def fu_get_uid(user) #:nodoc:
return nil unless user
case user
Expand All @@ -1094,6 +1089,7 @@ def fu_get_uid(user) #:nodoc:
when /\A\d+\z/
user.to_i
else
require 'etc'
Etc.getpwnam(user) ? Etc.getpwnam(user).uid : nil
end
end
Expand All @@ -1107,6 +1103,7 @@ def fu_get_gid(group) #:nodoc:
when /\A\d+\z/
group.to_i
else
require 'etc'
Etc.getgrnam(group) ? Etc.getgrnam(group).gid : nil
end
end
Expand Down

0 comments on commit 5814e3b

Please sign in to comment.