File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1
1
local Path = require " plenary.path"
2
2
local path = Path .path
3
3
4
- -- NOTE: breaking this could break tests
4
+ --- Construct a temporary environment which keeps track of which Paths have
5
+ --- been created for easier cleanup. Use `new_path()` to construct a Path.
5
6
local function new_env ()
6
7
local env , trash = {}, {}
7
8
9
+ --- Create and return a new Path instance with a non-existing temporary filename,
10
+ --- or `opts.filename` if provided. The temporary filename will be an absolute path.
11
+ --- Pass `opts.touch` to create the file as well.
8
12
function env .new_path (opts )
9
13
opts = opts or {}
10
14
local ret = Path :new (opts .filename or vim .fn .tempname ())
@@ -16,6 +20,8 @@ local function new_env()
16
20
return ret
17
21
end
18
22
23
+ --- Remove from the filesystem all paths created by `new_path()`. A
24
+ --- reference to this function may be passed directly to `after_each()`.
19
25
function env .cleanup ()
20
26
for _ , v in ipairs (trash ) do
21
27
if type ((v or {}).rm ) == " function" then
You can’t perform that action at this time.
0 commit comments