Skip to content

Commit 15780e4

Browse files
committed
Update install.lua
1 parent cb1e422 commit 15780e4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

install.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,32 @@ local function checkfilesexists(listfile)
4545
return false
4646
end
4747
function main()
48-
48+
local homepath=os.getenv('HOME')
49+
if not homepath then
50+
homepath=os.getenv('USERPROFILE')
51+
end
52+
53+
local downloadpath=path.join(homepath,"cache",'downloads')
4954
local name = "leetcode-treenode-cpp"
5055
local version = "1.1.9"
5156
local folder = name .. "-" .. version
52-
local archivefile = path.join('downloads', folder .. '.tar.gz')
53-
local listfile = path.join('downloads', folder .. '.list')
57+
local archivefile = path.join(downloadpath, folder .. '.tar.gz')
58+
local listfile = path.join(downloadpath, folder .. '.list')
5459
if checkfilesexists(listfile) then return end
5560
if not os.exists(archivefile) then
5661
local url = 'https://ghproxy.com/https://github.com/masx200/' .. name ..
5762
'/archive/' .. version .. '.tar.gz'
5863
print('download url:' .. url .. " to file:" .. archivefile)
5964
download(url, archivefile)
6065
end
61-
local outputdir = path.join('downloads', folder)
66+
local outputdir = path.join(downloadpath, folder)
6267
if os.exists(outputdir) then
6368
print("remove folder:" .. outputdir)
6469
os.rmdir(outputdir)
6570
end
6671
print('extract file:' .. archivefile .. " to folder:" .. outputdir)
6772
extract(archivefile, outputdir)
68-
local src = path.join('downloads', folder, folder)
73+
local src = path.join(downloadpath, folder, folder)
6974
if os.exists(name) then
7075
print("remove folder:" .. name)
7176
os.rmdir(name)

0 commit comments

Comments
 (0)