Copy to output for version 1.0
This commit is contained in:
parent
9f9cff55fa
commit
31a36815f8
3 changed files with 33 additions and 3 deletions
1
BeefSpace_Lock.toml
Normal file
1
BeefSpace_Lock.toml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
FileVersion = 1
|
|
@ -1,7 +1,5 @@
|
||||||
namespace Example_Website;
|
namespace Example_Website;
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
using Aven;
|
using Aven;
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
|
@ -9,7 +7,8 @@ class Program
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
Aven aven = scope .();
|
Aven aven = scope .();
|
||||||
aven.Register(.Owning(new Example_Website.Index()));
|
aven.CopyToOutput("../favicon.ico", "favicon.ico");
|
||||||
|
aven.Register(.Owning(new Index()));
|
||||||
aven.Build();
|
aven.Build();
|
||||||
}
|
}
|
||||||
}
|
}
|
30
src/Aven.bf
30
src/Aven.bf
|
@ -9,6 +9,7 @@ using System.Collections;
|
||||||
class Aven
|
class Aven
|
||||||
{
|
{
|
||||||
private List<Template> _templates = new .() ~ DeleteContainerAndItems!(_);
|
private List<Template> _templates = new .() ~ DeleteContainerAndItems!(_);
|
||||||
|
private Dictionary<String, String> _toCopy = new .() ~ DeleteDictionaryAndKeysAndValues!(_);
|
||||||
private Stopwatch _timer = new .() ~ delete _;
|
private Stopwatch _timer = new .() ~ delete _;
|
||||||
|
|
||||||
///Registers an instance of a web template
|
///Registers an instance of a web template
|
||||||
|
@ -24,6 +25,8 @@ class Aven
|
||||||
return .Err;
|
return .Err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CopyToOutput(StringView path, StringView output) => _toCopy.Add(new .(path), new .(output));
|
||||||
|
|
||||||
public void Build(StringView outputDir = "./output")
|
public void Build(StringView outputDir = "./output")
|
||||||
{
|
{
|
||||||
_timer.Start();
|
_timer.Start();
|
||||||
|
@ -80,6 +83,33 @@ class Aven
|
||||||
}
|
}
|
||||||
Log.Info(scope $"Wrote to file: {outputDir}{page.OutputFile}");
|
Log.Info(scope $"Wrote to file: {outputDir}{page.OutputFile}");
|
||||||
}
|
}
|
||||||
|
Log.Info("Finished page generation");
|
||||||
|
Log.Info("Copy to output");
|
||||||
|
|
||||||
|
|
||||||
|
for(var cp in _toCopy)
|
||||||
|
{
|
||||||
|
String dir = scope .();
|
||||||
|
if(File.Exists(cp.key))
|
||||||
|
{
|
||||||
|
if((cp.value.Contains('/') || cp.value.Contains('\\')) && Path.GetDirectoryPath(cp.value, dir) case .Ok)
|
||||||
|
Directory.CreateDirectory(scope $"{outputDir}/{dir}").IgnoreError();
|
||||||
|
|
||||||
|
if(File.Copy(cp.key, scope $"{outputDir}/{cp.value}") case .Err)
|
||||||
|
Log.Warn("Unable to copy over file");
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(Directory.Exists(cp.key))
|
||||||
|
{
|
||||||
|
if((cp.value.Contains('/') || cp.value.Contains('\\')) && Path.GetDirectoryPath(cp.value, dir) case .Ok)
|
||||||
|
Directory.CreateDirectory(scope $"{outputDir}/{dir}").IgnoreError();
|
||||||
|
|
||||||
|
if(Directory.Copy(cp.key, scope $"{outputDir}/{cp.value}") case .Err)
|
||||||
|
Log.Warn("Unable to copy over directory");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Log.Warn("Input file doesnt exist");
|
||||||
|
}
|
||||||
|
|
||||||
Log.Info(scope $"Finished generation in: {_timer.ElapsedMilliseconds}ms");
|
Log.Info(scope $"Finished generation in: {_timer.ElapsedMilliseconds}ms");
|
||||||
_timer.Reset();
|
_timer.Reset();
|
||||||
|
|
Loading…
Add table
Reference in a new issue