2021-09-27 12:42:46 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Wabbajack.DTOs;
|
|
|
|
using Wabbajack.DTOs.Directives;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.Compiler.CompilationSteps;
|
|
|
|
|
|
|
|
public class IgnorePathContains : ACompilationStep
|
2019-10-30 12:29:06 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
private readonly string _pattern;
|
|
|
|
private readonly string _reason;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public IgnorePathContains(ACompiler compiler, string pattern) : base(compiler)
|
|
|
|
{
|
|
|
|
_pattern = $"\\{pattern.Trim('\\')}\\";
|
|
|
|
_reason = $"Ignored because path contains {_pattern}";
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
|
|
|
{
|
|
|
|
if (!((string) source.Path).Contains(_pattern)) return null;
|
|
|
|
var result = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
result.Reason = _reason;
|
|
|
|
return result;
|
2019-10-30 12:29:06 +00:00
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|