Skip to content

Commit

Permalink
Recursive Walk Down Target Dir (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBakerEffendi authored Nov 29, 2023
1 parent 202f92a commit 0815c50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches: [master, main]
tags: ["*"]
paths-ignore: ['**.md']

concurrency: production

Expand Down
12 changes: 10 additions & 2 deletions DotNetAstGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 0815c50

Please sign in to comment.