From 4bcc7b14b9c04eecf57d9d3be6a8717e20ef26e7 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 24 Sep 2024 08:37:23 -0700 Subject: [PATCH] check if angular.json exists --- .../codemods/migrate/angular/NodeBasedRecipe.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openrewrite/codemods/migrate/angular/NodeBasedRecipe.java b/src/main/java/org/openrewrite/codemods/migrate/angular/NodeBasedRecipe.java index d037339..82f750f 100644 --- a/src/main/java/org/openrewrite/codemods/migrate/angular/NodeBasedRecipe.java +++ b/src/main/java/org/openrewrite/codemods/migrate/angular/NodeBasedRecipe.java @@ -97,7 +97,13 @@ public Collection generate(Accumulator acc, ExecutionConte private void runNode(Accumulator acc, ExecutionContext ctx) { Path dir = acc.getDirectory(); - // Path nodeModules = RecipeResources.from(getClass()).init(ctx); + + Path angularJsonPath = dir.resolve("angular.json"); + // Check if the file exists + if (!Files.exists(angularJsonPath)) { + throw new RuntimeException("angular.json file not found in the project directory: " + dir); + } + Path nodeModules = createDirectory(ctx, "recipe-run-modules"); boolean useNvmExec = useNvmExec(acc, ctx); List command = getNpmCommand(acc, ctx);