2019-12-04 01:26:26 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Newtonsoft.Json;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib.CompilationSteps
|
|
|
|
|
{
|
|
|
|
|
public class IgnorePathContains : ACompilationStep
|
|
|
|
|
{
|
|
|
|
|
private readonly string _pattern;
|
|
|
|
|
private readonly string _reason;
|
|
|
|
|
|
2019-11-03 16:45:49 +00:00
|
|
|
|
public IgnorePathContains(ACompiler compiler, string pattern) : base(compiler)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
|
|
|
|
_pattern = $"\\{pattern.Trim('\\')}\\";
|
|
|
|
|
_reason = $"Ignored because path contains {_pattern}";
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 01:26:26 +00:00
|
|
|
|
public override async ValueTask<Directive> Run(RawSourceFile source)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
|
|
|
|
if (!source.Path.Contains(_pattern)) return null;
|
|
|
|
|
var result = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
|
result.Reason = _reason;
|
|
|
|
|
return result;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IState GetState()
|
|
|
|
|
{
|
|
|
|
|
return new State(_pattern);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonObject("IgnorePathContains")]
|
|
|
|
|
public class State : IState
|
|
|
|
|
{
|
|
|
|
|
public State()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public State(string pattern)
|
|
|
|
|
{
|
|
|
|
|
Pattern = pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Pattern { get; set; }
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
2019-11-03 16:45:49 +00:00
|
|
|
|
public ICompilationStep CreateStep(ACompiler compiler)
|
2019-10-31 02:24:42 +00:00
|
|
|
|
{
|
|
|
|
|
return new IgnorePathContains(compiler, Pattern);
|
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-04 01:26:26 +00:00
|
|
|
|
}
|