Add file lua value
This commit is contained in:
@@ -21,7 +21,9 @@ type CaptureGroup struct {
|
||||
}
|
||||
|
||||
// ProcessContent applies regex replacement with Lua processing
|
||||
func ProcessRegex(content string, command utils.ModifyCommand) ([]utils.ReplaceCommand, error) {
|
||||
// The filename here exists ONLY so we can pass it to the lua environment
|
||||
// It's not used for anything else
|
||||
func ProcessRegex(content string, command utils.ModifyCommand, filename string) ([]utils.ReplaceCommand, error) {
|
||||
var commands []utils.ReplaceCommand
|
||||
logger.Trace("Processing regex: %q", command.Regex)
|
||||
|
||||
@@ -79,6 +81,7 @@ func ProcessRegex(content string, command utils.ModifyCommand) ([]utils.ReplaceC
|
||||
logger.Error("Error creating Lua state: %v", err)
|
||||
return commands, fmt.Errorf("error creating Lua state: %v", err)
|
||||
}
|
||||
L.SetGlobal("file", lua.LString(filename))
|
||||
// Hmm... Maybe we don't want to defer this..
|
||||
// Maybe we want to close them every iteration
|
||||
// We'll leave it as is for now
|
||||
@@ -205,7 +208,7 @@ func ProcessRegex(content string, command utils.ModifyCommand) ([]utils.ReplaceC
|
||||
|
||||
for _, capture := range captureGroups {
|
||||
if capture.Value == capture.Updated {
|
||||
logger.Info("Capture group unchanged: %s", capture.Value)
|
||||
logger.Info("Capture group unchanged: %s", LimitString(capture.Value, 50))
|
||||
continue
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user