From 8f0f0d8dc992607f30fad427a00a6812045ee744 Mon Sep 17 00:00:00 2001 From: Bryce Tompkins <167870666+bryceatmoderne@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:48:45 -0400 Subject: [PATCH] Set DOTNET_UPGRADEASSISTANT_TELEMETRY_OPTOUT environment variable when exec'ing upgrade-assistant (#3) --- .../openrewrite/dotnet/UpgradeAssistantRecipe.java | 11 +++++------ src/main/resources/META-INF/rewrite/category.yml | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/openrewrite/dotnet/UpgradeAssistantRecipe.java b/src/main/java/org/openrewrite/dotnet/UpgradeAssistantRecipe.java index ddf5e5e..6a160e5 100644 --- a/src/main/java/org/openrewrite/dotnet/UpgradeAssistantRecipe.java +++ b/src/main/java/org/openrewrite/dotnet/UpgradeAssistantRecipe.java @@ -132,11 +132,9 @@ protected void execUpgradeAssistant(Path inputFile, Accumulator acc, ExecutionCo } processOutput(inputFile, out, acc); } - } catch ( - IOException e) { + } catch (IOException e) { throw new UncheckedIOException(e); - } catch ( - InterruptedException e) { + } catch (InterruptedException e) { throw new RuntimeException(e); } finally { deleteFile(out); @@ -147,6 +145,7 @@ protected void execUpgradeAssistant(Path inputFile, Accumulator acc, ExecutionCo private Map buildUpgradeAssistantEnv() { Map env = new HashMap<>(); env.put("TERM", "dumb"); + env.put("DOTNET_UPGRADEASSISTANT_TELEMETRY_OPTOUT", "1"); String path = System.getenv("PATH"); // This is required to find .NET SDKs env.put("PATH", path + File.pathSeparator + DOTNET_HOME); @@ -157,8 +156,8 @@ protected void deleteFile(@Nullable Path path) { if (path != null) { try { Files.deleteIfExists(path); - } catch (IOException e) { - // FIXME recipe logger? + } catch (IOException ignored) { + // Ignored } } } diff --git a/src/main/resources/META-INF/rewrite/category.yml b/src/main/resources/META-INF/rewrite/category.yml index 2de6ab1..e91c4b2 100644 --- a/src/main/resources/META-INF/rewrite/category.yml +++ b/src/main/resources/META-INF/rewrite/category.yml @@ -16,7 +16,7 @@ --- type: specs.openrewrite.org/v1beta/category -name: .Net +name: .NET packageName: org.openrewrite.dotnet description: Recipes to migrate projects using .NET tools. ---