Skip to content

Commit 36aaceb

Browse files
authored
fix(path): dont use Path:expand internally (#499)
1 parent 499e074 commit 36aaceb

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lua/plenary/path.lua

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,7 @@ function Path:parents()
708708
end
709709

710710
function Path:is_file()
711-
local stat = uv.fs_stat(self:expand())
712-
if stat then
713-
return stat.type == "file" and true or nil
714-
end
711+
return self:_stat().type == "file" and true or nil
715712
end
716713

717714
-- TODO:
@@ -725,7 +722,7 @@ function Path:write(txt, flag, mode)
725722

726723
mode = mode or 438
727724

728-
local fd = assert(uv.fs_open(self:expand(), flag, mode))
725+
local fd = assert(uv.fs_open(self:_fs_filename(), flag, mode))
729726
assert(uv.fs_write(fd, txt, -1))
730727
assert(uv.fs_close(fd))
731728
end
@@ -735,7 +732,7 @@ end
735732
function Path:_read()
736733
self = check_self(self)
737734

738-
local fd = assert(uv.fs_open(self:expand(), "r", 438)) -- for some reason test won't pass with absolute
735+
local fd = assert(uv.fs_open(self:_fs_filename(), "r", 438)) -- for some reason test won't pass with absolute
739736
local stat = assert(uv.fs_fstat(fd))
740737
local data = assert(uv.fs_read(fd, stat.size, 0))
741738
assert(uv.fs_close(fd))
@@ -777,7 +774,7 @@ function Path:head(lines)
777774
self = check_self(self)
778775
local chunk_size = 256
779776

780-
local fd = uv.fs_open(self:expand(), "r", 438)
777+
local fd = uv.fs_open(self:_fs_filename(), "r", 438)
781778
if not fd then
782779
return
783780
end
@@ -820,7 +817,7 @@ function Path:tail(lines)
820817
self = check_self(self)
821818
local chunk_size = 256
822819

823-
local fd = uv.fs_open(self:expand(), "r", 438)
820+
local fd = uv.fs_open(self:_fs_filename(), "r", 438)
824821
if not fd then
825822
return
826823
end
@@ -884,7 +881,7 @@ end
884881
function Path:readbyterange(offset, length)
885882
self = check_self(self)
886883

887-
local fd = uv.fs_open(self:expand(), "r", 438)
884+
local fd = uv.fs_open(self:_fs_filename(), "r", 438)
888885
if not fd then
889886
return
890887
end

0 commit comments

Comments
 (0)