Sha256: 5454ea8088245e35ccdec1097b3f0b12bdfda509eabb57e03fa29d5d25f424fa
Contents?: true
Size: 1.11 KB
Versions: 17
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true require 'fileutils' require 'aruba/api' require 'lolcommits/platform' module PathHelpers def reject_paths_with_cmd(cmd) # make a new subdir that still contains cmds tmpbindir = expand_path('./bin') FileUtils.mkdir_p tmpbindir preseve_cmds_in_path(%w(git mplayer), tmpbindir) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] newpaths = ENV['PATH'].split(File::PATH_SEPARATOR).reject do |path| found_cmd = false exts.each do |ext| exe = "#{path}/#{cmd}#{ext}" found_cmd = true if File.executable? exe end found_cmd end # add the temporary directory with git in it back into the path newpaths << tmpbindir # use aruba/api set_environment_variable to set PATH, which will be automaticaly restored set_environment_variable 'PATH', newpaths.join(File::PATH_SEPARATOR) end def preseve_cmds_in_path(cmds, tmpbindir) cmds.each do |cmd| whichcmd = Lolcommits::Platform.command_which(cmd) FileUtils.ln_s whichcmd, File.join(tmpbindir, File.basename(whichcmd)) unless whichcmd.nil? end end end
Version data entries
17 entries across 17 versions & 1 rubygems