mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Remove dependency on unzip.
Use tar instead which should be available on default Unixes and Windows
This commit is contained in:
parent
73ef705eb2
commit
40edefc476
1 changed files with 34 additions and 9 deletions
|
|
@ -37,6 +37,30 @@ local function get_revision(lang)
|
|||
return (lockfile[lang] and lockfile[lang].revision)
|
||||
end
|
||||
|
||||
local function select_mkdir_cmd(directory, cwd, info_msg)
|
||||
if fn.has('win32') == 1 then
|
||||
return {
|
||||
cmd = 'cmd',
|
||||
opts = {
|
||||
args = { '/C', 'mkdir', directory},
|
||||
cwd = cwd,
|
||||
},
|
||||
info = info_msg,
|
||||
err = "Could not create "..directory,
|
||||
}
|
||||
else
|
||||
return {
|
||||
cmd = 'mkdir',
|
||||
opts = {
|
||||
args = { directory },
|
||||
cwd = cwd,
|
||||
},
|
||||
info = info_msg,
|
||||
err = "Could not create "..directory,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local function select_rm_file_cmd(file, info_msg)
|
||||
if fn.has('win32') == 1 then
|
||||
return {
|
||||
|
|
@ -182,7 +206,7 @@ local function select_mv_cmd(from, to, cwd)
|
|||
end
|
||||
|
||||
local function select_download_commands(repo, project_name, cache_folder, revision)
|
||||
if vim.fn.executable('unzip') == 1 and vim.fn.executable('curl') == 1 and repo.url:find("github.com", 1, true) then
|
||||
if vim.fn.executable('tar') == 1 and vim.fn.executable('curl') == 1 and repo.url:find("github.com", 1, true) then
|
||||
|
||||
revision = revision or repo.branch or "master"
|
||||
local path_sep = utils.get_path_sep()
|
||||
|
|
@ -195,28 +219,29 @@ local function select_download_commands(repo, project_name, cache_folder, revisi
|
|||
opts = {
|
||||
args = {
|
||||
'-L', -- follow redirects
|
||||
repo.url.."/archive/"..revision..".zip",
|
||||
repo.url.."/archive/"..revision..".tar.gz",
|
||||
'--output',
|
||||
project_name..".zip"
|
||||
project_name..".tar.gz"
|
||||
},
|
||||
cwd = cache_folder,
|
||||
},
|
||||
},
|
||||
select_mkdir_cmd(project_name..'-tmp', cache_folder, 'Creating temporary directory'),
|
||||
{
|
||||
cmd = 'unzip',
|
||||
cmd = 'tar',
|
||||
info = 'Extracting...',
|
||||
err = 'Error during unzipping',
|
||||
err = 'Error during tarball extraction.',
|
||||
opts = {
|
||||
args = {
|
||||
'-o',
|
||||
project_name..".zip",
|
||||
'-d',
|
||||
'-xvf',
|
||||
project_name..".tar.gz",
|
||||
'-C',
|
||||
project_name..'-tmp',
|
||||
},
|
||||
cwd = cache_folder,
|
||||
},
|
||||
},
|
||||
select_rm_file_cmd(cache_folder..path_sep..project_name..".zip"),
|
||||
select_rm_file_cmd(cache_folder..path_sep..project_name..".tar.gz"),
|
||||
select_mv_cmd(utils.join_path(project_name..'-tmp', repo.url:match('[^/]-$')..'-'..revision),
|
||||
project_name,
|
||||
cache_folder),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue