From 0f6ea75046c10254d759ca7e361b8e9cbc8e9156 Mon Sep 17 00:00:00 2001 From: The1111mp Date: Wed, 16 Oct 2024 21:41:08 +0800 Subject: [PATCH] fix: `nvmd use {version} --project` throws an error when `.nvmd/projects.json` does not exist (https://github.com/1111mp/nvm-desktop/issues/130) Signed-off-by: The1111mp --- src/run/nvmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run/nvmd.rs b/src/run/nvmd.rs index 21b1bd6..47882f9 100644 --- a/src/run/nvmd.rs +++ b/src/run/nvmd.rs @@ -321,7 +321,7 @@ fn update_projects_file( ) -> Result<()> { if let Some(mut projects_path) = NVMD_PATH.clone() { projects_path.push("projects.json"); - let mut json_obj = read_json(&projects_path)?; + let mut json_obj = read_json(&projects_path).unwrap_or(json!([])); let mut not_exist = true; if let Some(projects) = json_obj.as_array_mut() { for project in projects.iter_mut() {