Fixes chefstyle & move etc require to block

Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
This commit is contained in:
Vivek Singh 2020-12-02 11:11:02 +05:30
parent 896e5fa261
commit 5162ab4904

View file

@ -1,24 +1,21 @@
require_relative "utils/install_context"
require 'etc' unless defined?(Etc)
module Inspec
extend Inspec::InstallContextHelpers
def self.config_dir
begin
home = Dir.home
rescue ArgumentError, NoMethodError
# $HOME is not set in systemd service File.expand_path('~') will not work here
home = Etc.getpwuid(Process.uid).dir
end
ENV["INSPEC_CONFIG_DIR"] ? ENV["INSPEC_CONFIG_DIR"] : File.join(home, ".inspec")
def self.config_dir
ENV["INSPEC_CONFIG_DIR"] || File.join(home_path, ".inspec")
end
def self.src_root
@src_root ||= File.expand_path(File.join(__FILE__, "../../.."))
end
def self.home_path
Dir.home
rescue ArgumentError, NoMethodError
# $HOME is not set in systemd service File.expand_path('~') will not work here
require "etc" unless defined?(Etc)
Etc.getpwuid(Process.uid).dir
end
end