From a738e05dbd3cabde3a7216579c7713e492fec81e Mon Sep 17 00:00:00 2001 From: James Yu Date: Thu, 23 Nov 2023 15:56:44 +0000 Subject: [PATCH] Ensure previous recipe exists before using --- src/compile/recipe.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/compile/recipe.ts b/src/compile/recipe.ts index 7d6931ceb..3d8bfd56f 100644 --- a/src/compile/recipe.ts +++ b/src/compile/recipe.ts @@ -265,15 +265,14 @@ function findRecipe(rootFile: string, langId: string, recipeName?: string): Reci recipeName = defaultRecipeName } if (recipeName) { - const candidates = recipes.filter(candidate => candidate.name === recipeName) - if (candidates.length < 1) { + recipe = recipes.find(candidate => candidate.name === recipeName) + if (recipe) { logger.log(`Failed to resolve build recipe: ${recipeName}.`) void logger.showErrorMessage(`[Builder] Failed to resolve build recipe: ${recipeName}.`) } - recipe = candidates[0] } // Find default recipe of last used - if (recipe === undefined && defaultRecipeName === 'lastUsed') { + if (recipe === undefined && defaultRecipeName === 'lastUsed' && recipes.find(candidate => candidate.name === prevRecipe?.name)) { recipe = prevRecipe } // If still not found, fallback to 'first'