Merge pull request #9998 from chrisroberts/f-plat-wsl-pathname
Always force string type conversion of path
This commit is contained in:
commit
2ba5c74e1c
|
@ -392,8 +392,9 @@ module Vagrant
|
|||
# @param [String, Pathname] path Path to convert
|
||||
# @return [String]
|
||||
def wsl_to_windows_path(path)
|
||||
path = path.to_s
|
||||
if wsl? && wsl_windows_access? && !path.match(/^[a-zA-Z]:/)
|
||||
path = File.expand_path(path.to_s)
|
||||
path = File.expand_path(path)
|
||||
if wsl_path?(path)
|
||||
parts = path.split("/")
|
||||
parts.delete_if(&:empty?)
|
||||
|
@ -405,13 +406,13 @@ module Vagrant
|
|||
end
|
||||
path = [root_path, *parts].join("\\")
|
||||
else
|
||||
path = path.to_s.sub("/mnt/", "")
|
||||
path = path.sub("/mnt/", "")
|
||||
parts = path.split("/")
|
||||
parts.first << ":"
|
||||
path = parts.join("\\")
|
||||
end
|
||||
end
|
||||
path.to_s
|
||||
path
|
||||
end
|
||||
|
||||
# Takes a windows path and formats it to the
|
||||
|
|
|
@ -353,6 +353,10 @@ describe Vagrant::Util::Platform do
|
|||
it "should include rootfs when accessing non-home path" do
|
||||
expect(subject.wsl_to_windows_path("/tmp/test")).to include("rootfs")
|
||||
end
|
||||
|
||||
it "should properly handle Pathname" do
|
||||
expect(subject.wsl_to_windows_path(Pathname.new("/tmp/test"))).to include("rootfs")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue