mirror of
https://github.com/pesde-pkg/tooling.git
synced 2025-03-03 18:41:45 +00:00
refactor(lib): use declared tool dir and use assert
to handle nil
This commit is contained in:
parent
8cea7bef8a
commit
57605e87b8
1 changed files with 2 additions and 2 deletions
|
@ -173,13 +173,13 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number
|
|||
barFns.start(bar) -- init
|
||||
|
||||
-- If the tool installation directory was not present, we create it
|
||||
local toolDir = Option.from(installPath:parent()):unwrap()
|
||||
local toolDir = assert(installPath:parent(), "Install path did not have parent dir")
|
||||
if not pathfs.isDir(toolDir) then
|
||||
pathfs.writeDir(toolDir)
|
||||
end
|
||||
|
||||
-- Attempt to read an existing lock in EAFP fashion
|
||||
local installLockFile = assert(installPath:parent(), "Install path did not have parent dir"):join("LOCK")
|
||||
local installLockFile = toolDir:join("LOCK")
|
||||
local isLocked, existingInstallPath = pcall(pathfs.readFile, installLockFile)
|
||||
if isLocked then
|
||||
-- If the lock was held and we know the same tool that we are trying to install
|
||||
|
|
Loading…
Add table
Reference in a new issue