Skip to content
This repository has been archived by the owner on Jul 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from tversteeg/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
shohi committed Jul 17, 2021
2 parents 5c308cd + 3fc8643 commit c6ab820
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions neva
Expand Up @@ -75,16 +75,15 @@ function split(s, delimiter)
end
end

return result;
return result
end

-- test if given directory is empty
-- https://unix.stackexchange.com/questions/202243/how-to-check-directory-is-empty
-- NOTE: the input must be a directory
local function is_dir_empty(dir)
local cmd = string.format("ls -1qA %s | grep -q '.'", dir)
if not os.execute(cmd) then return true end
return false
return not os.execute(cmd)
end

-- extract the basename of given filepath, suffix is not trimed.
Expand Down Expand Up @@ -166,10 +165,9 @@ local function download_url(version)
end

if OS_TYPE == "linux" then
return NVIM_BASE_URL ..
string.format("/%s/nvim-linux64.tar.gz", version)
return string.format("%s/%s/nvim-linux64.tar.gz", NVIM_BASE_URL, version)
elseif OS_TYPE == "darwin" or OS_TYPE == "mac" then
return NVIM_BASE_URL .. string.format("/%s/nvim-macos.tar.gz", version)
return string.format("%s/%s/nvim-macos.tar.gz", NVIM_BASE_URL, version)
end
end

Expand All @@ -185,9 +183,7 @@ local function version_path(version) return NEVA_VER_HOME .. "/" .. version end
-- remove dir using `rm -rf`
local function remove_dir(dir)
local cmd = string.format("rm -rf %s", dir)
if not os.execute(cmd) then return false end

return true
return not os.execute(cmd)
end

local function check_version(version, info)
Expand All @@ -212,18 +208,12 @@ end

local function create_symlink(target, link)
local cmd = string.format("ln -sf %s %s", target, link)
if not os.execute(cmd) then return false end

return true
return not os.execute(cmd)
end

local function remove_symlink(link)
local lk = expand_home(link)
if os.remove(lk) then
return true
else
return false
end
return os.remove(lk) ~= nil
end

-- clean removes downloaded tar file,
Expand Down Expand Up @@ -439,9 +429,7 @@ local function parse_command(args)
end

local cmd = args[1]
if cmd then return cmd end

return "help"
return cmd or "help"
end

-- main is the entry.
Expand Down

0 comments on commit c6ab820

Please sign in to comment.