From 0815c50db61799170ed6e666fe6b754ce44dbf7d Mon Sep 17 00:00:00 2001 From: David Baker Effendi Date: Wed, 29 Nov 2023 12:02:46 +0200 Subject: [PATCH] Recursive Walk Down Target Dir (#10) --- .github/workflows/release.yml | 1 + DotNetAstGen/Program.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11c1ede..de35e6f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: branches: [master, main] tags: ["*"] + paths-ignore: ['**.md'] concurrency: production diff --git a/DotNetAstGen/Program.cs b/DotNetAstGen/Program.cs index f7b949c..34f5252 100644 --- a/DotNetAstGen/Program.cs +++ b/DotNetAstGen/Program.cs @@ -48,7 +48,8 @@ private static void _RunAstGet(string inputPath, DirectoryInfo rootOutputPath) { _logger?.LogInformation("Parsing directory {dirName}", inputPath); var rootDirectory = new DirectoryInfo(inputPath); - foreach (var inputFile in new DirectoryInfo(inputPath).EnumerateFiles("*.cs")) + foreach (var inputFile in new DirectoryInfo(inputPath).EnumerateFiles("*.cs", + SearchOption.AllDirectories)) { _AstForFile(rootDirectory, rootOutputPath, inputFile); } @@ -89,7 +90,14 @@ private static void _AstForFile(FileSystemInfo rootInputPath, FileSystemInfo roo var outputName = Path.Combine(filePath.DirectoryName ?? "./", $"{Path.GetFileNameWithoutExtension(fullPath)}.json") .Replace(rootInputPath.FullName, rootOutputPath.FullName); - + + // Create dirs if they do not exist + var outputParentDir = Path.GetDirectoryName(outputName); + if (outputParentDir != null) + { + Directory.CreateDirectory(outputParentDir); + } + File.WriteAllText(outputName, jsonString); _logger?.LogInformation("Successfully wrote AST to '{astJsonPath}'", outputName); }