From 4b86e055e971326c6957a5358bb00c1e068bf149 Mon Sep 17 00:00:00 2001 From: Vladimir Vagaytsev Date: Tue, 14 May 2024 11:30:27 +0200 Subject: [PATCH] fix: throw if no actions found by pattern matching --- core/src/graph/config-graph.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/graph/config-graph.ts b/core/src/graph/config-graph.ts index 71d12dad6d..991cd2d0cf 100644 --- a/core/src/graph/config-graph.ts +++ b/core/src/graph/config-graph.ts @@ -153,12 +153,15 @@ export abstract class BaseConfigGraph< getModule(name: string, includeDisabled?: boolean) { return this.moduleGraph.getModule(name, includeDisabled) } + getModules(params: GetManyParams = {}) { return this.moduleGraph.getModules(params) } + withDependantModules(modules: GardenModule[]) { return this.moduleGraph.withDependantModules(modules) } + // and sanity... ////////////////// @@ -248,7 +251,11 @@ export abstract class BaseConfigGraph< return true }) - if (!ignoreMissing && names && names.length > found.length) { + if (ignoreMissing) { + return found + } + + if ((names && names.length) || 0 > found.length) { const missing = difference(names, foundNames) throw new GraphError({ @@ -256,6 +263,12 @@ export abstract class BaseConfigGraph< }) } + if (includeNames && includeNames.length > 0 && found.length === 0) { + throw new GraphError({ + message: `Could not find one or more ${kind} actions for patterns: ${naturalList(includeNames)}`, + }) + } + return found }