2021-09-27 12:42:46 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Wabbajack.DTOs;
|
|
|
|
using Wabbajack.DTOs.Directives;
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
#pragma warning disable 1998
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.Compiler.CompilationSteps;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public class IgnoreInPath : ACompilationStep
|
|
|
|
{
|
|
|
|
private readonly RelativePath _prefix;
|
|
|
|
private readonly string _reason;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public IgnoreInPath(ACompiler compiler, RelativePath prefix) : base(compiler)
|
|
|
|
{
|
|
|
|
_prefix = prefix;
|
|
|
|
_reason = $"Ignored because path starts with {_prefix}";
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
|
|
|
{
|
|
|
|
if (!source.Path.InFolder(_prefix))
|
|
|
|
return null;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
var result = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
result.Reason = _reason;
|
|
|
|
return result;
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|
|
|
|
}
|