Skip to content

Commit

Permalink
fix(output): Create output folder
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTWF authored Apr 15, 2022
2 parents b0c27ac + d3e3007 commit 50b948f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Compiler/Output/OutputFileStreamFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Compiler.Output
{
public class OutputFileStreamFactory: IOutputStreamFactory
public class OutputFileStreamFactory : IOutputStreamFactory
{
public TextWriter Make(string file)
{
Directory.CreateDirectory(Path.GetDirectoryName(file)!);
return new StreamWriter(file);
}
}
}
}
5 changes: 3 additions & 2 deletions src/Compiler/Output/OutputWriterFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Compiler.Argument;
using System.IO;
using Compiler.Argument;
using Compiler.Transformer;

namespace Compiler.Output
Expand All @@ -13,4 +14,4 @@ public static OutputWriter Make(CompilerArguments arguments, string file, IOutpu
);
}
}
}
}
4 changes: 2 additions & 2 deletions tests/CompilerTest/Output/OutputFileStreamFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class OutputFileStreamFactoryTest
[Fact]
public void TestItReturnsStreamWriter()
{
Assert.IsType<StreamWriter>(new OutputFileStreamFactory().Make("test"));
Assert.IsType<StreamWriter>(new OutputFileStreamFactory().Make("foo/test"));
}
}
}
}

0 comments on commit 50b948f

Please sign in to comment.