Skip to content

Commit 83213fa

Browse files
committed
Filter out non-existing projects
1 parent 7618e7e commit 83213fa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/cd-project/project-repo.lua

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ local json = require("cd-project.json")
66

77
---@return CdProject.Project[]
88
local get_projects = function()
9-
return json.read_or_init_json_file(vim.g.cd_project_config.projects_config_filepath)
9+
local json = json.read_or_init_json_file(vim.g.cd_project_config.projects_config_filepath)
10+
11+
-- Filter out projects whose directory does not exit
12+
local existing_projects = vim.tbl_filter(function(p)
13+
return vim.fn.isdirectory(p.path) == 1
14+
end, json)
15+
16+
return existing_projects
17+
1018
end
1119

1220
---@param projects CdProject.Project[]

0 commit comments

Comments
 (0)