Change usage of Dir.home to Inspec.config_dir (#3567)

This prevents errors on systems without `ENV['HOME']` (e.g. Habitat
services) by allowing the specification of the location of `.inspec` via
`ENV['INSPEC_CONFIG_DIR']`.

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This commit is contained in:
Jerry Aldrich 2018-11-01 13:32:45 -07:00 committed by Jared Quick
parent 10e5292e27
commit 701dd9fb0b
2 changed files with 2 additions and 2 deletions

View file

@ -34,7 +34,7 @@ module Inspec
@paths += Dir[lib_home+'/inspec-*-*/lib/inspec-*rb']
# traverse out of inspec-vX.Y.Z/lib/inspec/plugins.rb
@home = home || File.join(Dir.home, '.inspec', 'plugins')
@home = home || File.join(Inspec.config_dir, 'plugins')
@paths += Dir[File.join(@home, '**{,/*/**}', '*.gemspec')]
.map { |x| File.dirname(x) }
.map { |x| Dir[File.join(x, 'lib', 'inspec-*.rb')] }

View file

@ -5,7 +5,7 @@ module InspecPlugins
# stores configuration on local filesystem
class Configuration
def initialize
@config_path = File.join(Dir.home, '.inspec', 'compliance')
@config_path = File.join(Inspec.config_dir, 'compliance')
# ensure the directory is available
unless File.directory?(@config_path)
FileUtils.mkdir_p(@config_path)