Skip to content

Commit

Permalink
Fix bug with cloning templates (#437)
Browse files Browse the repository at this point in the history
Fixes #436.
  • Loading branch information
epwalsh authored Feb 25, 2024
1 parent 7283ccf commit 76d76c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- Fixed regression with cloning templates where a directory was created instead of a file.

## [v3.5.2](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.5.2) - 2024-02-25

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lua/obsidian/templates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ M.clone_template = function(template_name, note_path, client, title)
return
end

note_path:mkdir { parents = true, exist_ok = true }
assert(note_path:parent()):mkdir { parents = true, exist_ok = true }

local template_path = Path:new(templates_dir) / template_name
local template_file = io.open(tostring(template_path), "r")
Expand Down
10 changes: 5 additions & 5 deletions test/obsidian/path_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,16 @@ describe("Path.mkdir()", function()
end)

it("should rename a directory", function()
local temp_file = Path.temp()
temp_file:mkdir()
assert.is_true(temp_file:is_dir())
local temp_dir = Path.temp()
temp_dir:mkdir()
assert.is_true(temp_dir:is_dir())

local target = Path.temp()
assert.is_false(target:exists())

temp_file:rename(target)
temp_dir:rename(target)
assert.is_true(target:is_dir())
assert.is_false(temp_file:is_dir())
assert.is_false(temp_dir:is_dir())

target:rmdir()
assert.is_false(target:exists())
Expand Down

0 comments on commit 76d76c6

Please sign in to comment.