Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
refactor: use CreateFile for new posts
Browse files Browse the repository at this point in the history
  • Loading branch information
biohazard999 committed Dec 12, 2019
1 parent e5c1e13 commit dcc8f94
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/Pretzel.Logic/Recipes/Recipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void Create()
CreateFile(@"Resources\Razor\Post.cshtml", directory, @"_layouts", "post.cshtml");
CreateFile(@"Resources\Razor\Index.cshtml", directory, "index.cshtml");
CreateFile(@"Resources\Razor\About.cshtml", directory, "about.md");
fileSystem.File.WriteAllText(Path.Combine(directory, @"_posts", string.Format("{0}-myfirstpost.md", DateTime.Today.ToString("yyyy-MM-dd"))), GetResourceString(@"Resources\Razor\FirstPost.cshtml"));
CreateFile(@"Resources\Razor\FirstPost.cshtml", directory, @"_posts", $"{DateTime.Today.ToString("yyyy-MM-dd")}-myfirstpost.md");
CreateFile(@"Resources\Style.css", directory, @"css", "style.css");
CreateFile(@"Resources\Razor\Config.cshtml", directory, "_config.yml");
CreateFile(@"Resources\Razor\Head.cshtml", directory, @"_includes", "head.cshtml");
Expand All @@ -82,7 +82,7 @@ public void Create()
CreateFile(@"Resources\Liquid\Post.liquid", directory, @"_layouts", "post.html");
CreateFile(@"Resources\Liquid\Index.liquid", directory, @"index.html");
CreateFile(@"Resources\Liquid\About.liquid", directory, @"about.md");
fileSystem.File.WriteAllText(Path.Combine(directory, @"_posts", string.Format("{0}-myfirstpost.md", DateTime.Today.ToString("yyyy-MM-dd"))), GetResourceString(@"Resources\Liquid\FirstPost.liquid"));
CreateFile(@"Resources\Liquid\FirstPost.liquid", directory, @"_posts", $"{DateTime.Today.ToString("yyyy-MM-dd")}-myfirstpost.md");
CreateFile(@"Resources\Style.css", directory, @"css", "style.css");
CreateFile(@"Resources\Liquid\Config.liquid", directory, @"_config.yml");
CreateFile(@"Resources\Liquid\Head.liquid", directory, @"_includes", "head.html");
Expand Down Expand Up @@ -183,15 +183,6 @@ private static Stream GetResourceStream(Type type, string path)
private Stream GetResourceStream(string path)
=> GetResourceStream(GetType(), path);

private string GetResourceString(string path)
{
using (var stream = GetResourceStream(path))
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}

private void CreateDirectories()
{
fileSystem.Directory.CreateDirectory(Path.Combine(directory, @"_posts"));
Expand Down

0 comments on commit dcc8f94

Please sign in to comment.