Skip to content

Commit

Permalink
Fix path creation with (just) a Project on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed Feb 12, 2024
1 parent d6c8e0d commit 729a9e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ path seperator of the host filesystem.
"""
function ensurepath(path::String)
if !ispath(path)
if endswith(path, DIRECTORY_SUFFIX_FLAG)
if endswith(path, DIRECTORY_SUFFIX_FLAG) || (Sys.iswindows() && endswith(path, "\\"))
mkpath(path[begin:prevind(path, end)])
else
mkpath(dirname(path))
Expand Down
8 changes: 4 additions & 4 deletions src/nt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ end

projectpath(p::Project, parent::String) =
joinpath(projectpath(p), if parent === DATA_HOME[] || parent in DATA_DIRS[]
"data"
"data\\"
elseif parent == CONFIG_HOME[] || parent in CONFIG_DIRS[]
"config"
"config\\"
elseif parent == CACHE_HOME[]
"cache"
"cache\\"
elseif parent == STATE_HOME[]
"state"
"state\\"
else
""
end)
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ elseif Sys.iswindows()
@testset "Projects" begin
@test BaseDirs.projectpath(BaseDirs.Project("a")) == "julia\\a\\"
@test BaseDirs.projectpath(BaseDirs.Project("a", org="b")) == "b\\a\\"
@test BaseDirs.projectpath(BaseDirs.Project("a"), BaseDirs.DATA_HOME[]) == "julia\\a\\data"
@test BaseDirs.projectpath(BaseDirs.Project("a"), BaseDirs.DATA_HOME[]) == "julia\\a\\data\\"
if BaseDirs.CONFIG_HOME[] != BaseDirs.DATA_HOME[]
@test BaseDirs.projectpath(BaseDirs.Project("a"), BaseDirs.CONFIG_HOME[]) == "julia\\a\\config"
@test BaseDirs.projectpath(BaseDirs.Project("a"), BaseDirs.CONFIG_HOME[]) == "julia\\a\\config\\"
end
@test BaseDirs.projectpath(BaseDirs.Project("a"), BaseDirs.CACHE_HOME[]) == "julia\\a\\cache"
@test BaseDirs.projectpath(BaseDirs.Project("a"), BaseDirs.STATE_HOME[]) == "julia\\a\\state"
@test BaseDirs.projectpath(BaseDirs.Project("a"), BaseDirs.CACHE_HOME[]) == "julia\\a\\cache\\"
@test BaseDirs.projectpath(BaseDirs.Project("a"), BaseDirs.STATE_HOME[]) == "julia\\a\\state\\"
end
@test isnothing(BaseDirs.reload())
end

0 comments on commit 729a9e3

Please sign in to comment.