Skip to content

Commit

Permalink
Ensure previous recipe exists before using
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Nov 23, 2023
1 parent 007fb2e commit a738e05
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/compile/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit a738e05

Please sign in to comment.