summaryrefslogtreecommitdiff
path: root/chef-utils/lib/chef-utils/dsl/path_sanity.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-07-22 17:24:48 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-07-22 17:24:48 -0700
commitdf3f9fa4f950827b028efb58b1403f8e4c6f3d08 (patch)
tree932e2f01d86c39f328ca9c5475e253efb4b0e06a /chef-utils/lib/chef-utils/dsl/path_sanity.rb
parentd7deaae8fcf84c19c825e43c487819cde24ed549 (diff)
downloadchef-df3f9fa4f950827b028efb58b1403f8e4c6f3d08.tar.gz
Convert to default_paths APIlcg/default-paths
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'chef-utils/lib/chef-utils/dsl/path_sanity.rb')
-rw-r--r--chef-utils/lib/chef-utils/dsl/path_sanity.rb29
1 files changed, 4 insertions, 25 deletions
diff --git a/chef-utils/lib/chef-utils/dsl/path_sanity.rb b/chef-utils/lib/chef-utils/dsl/path_sanity.rb
index 921c666124..1fbfbdccf3 100644
--- a/chef-utils/lib/chef-utils/dsl/path_sanity.rb
+++ b/chef-utils/lib/chef-utils/dsl/path_sanity.rb
@@ -15,42 +15,21 @@
# limitations under the License.
#
-require_relative "../internal"
-require_relative "platform_family"
+require_relative "default_paths"
module ChefUtils
module DSL
module PathSanity
- include Internal
+ include ChefUtils::DSL::DefaultPaths
- # @since 15.5
def sanitized_path(env = nil)
- env_path = env ? env["PATH"] : __env_path
- env_path = "" if env_path.nil?
- path_separator = ChefUtils.windows? ? ";" : ":"
- # ensure the Ruby and Gem bindirs are included for omnibus chef installs
- new_paths = env_path.split(path_separator)
- [ __ruby_bindir, __gem_bindir ].compact.each do |path|
- new_paths = [ path ] + new_paths unless new_paths.include?(path)
- end
- __sane_paths.each do |path|
- new_paths << path unless new_paths.include?(path)
- end
- new_paths.join(path_separator).encode("utf-8", invalid: :replace, undef: :replace)
+ default_paths(env)
end
private
def __sane_paths
- ChefUtils.windows? ? %w{} : %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}
- end
-
- def __ruby_bindir
- RbConfig::CONFIG["bindir"]
- end
-
- def __gem_bindir
- Gem.bindir
+ __default_paths
end
extend self