mirror of
https://github.com/inspec/inspec
synced 2024-11-14 00:47:10 +00:00
Fixes chefstyle & move etc require to block
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
This commit is contained in:
parent
896e5fa261
commit
5162ab4904
1 changed files with 9 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue