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
|
# @param [String, Pathname] path Path to convert
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def wsl_to_windows_path(path)
|
def wsl_to_windows_path(path)
|
||||||
|
path = path.to_s
|
||||||
if wsl? && wsl_windows_access? && !path.match(/^[a-zA-Z]:/)
|
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)
|
if wsl_path?(path)
|
||||||
parts = path.split("/")
|
parts = path.split("/")
|
||||||
parts.delete_if(&:empty?)
|
parts.delete_if(&:empty?)
|
||||||
|
@ -405,13 +406,13 @@ module Vagrant
|
||||||
end
|
end
|
||||||
path = [root_path, *parts].join("\\")
|
path = [root_path, *parts].join("\\")
|
||||||
else
|
else
|
||||||
path = path.to_s.sub("/mnt/", "")
|
path = path.sub("/mnt/", "")
|
||||||
parts = path.split("/")
|
parts = path.split("/")
|
||||||
parts.first << ":"
|
parts.first << ":"
|
||||||
path = parts.join("\\")
|
path = parts.join("\\")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
path.to_s
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Takes a windows path and formats it to the
|
# 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
|
it "should include rootfs when accessing non-home path" do
|
||||||
expect(subject.wsl_to_windows_path("/tmp/test")).to include("rootfs")
|
expect(subject.wsl_to_windows_path("/tmp/test")).to include("rootfs")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should properly handle Pathname" do
|
||||||
|
expect(subject.wsl_to_windows_path(Pathname.new("/tmp/test"))).to include("rootfs")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue