Skip to content

Commit

Permalink
v0.1.24
Browse files Browse the repository at this point in the history
  • Loading branch information
lassejlv committed Jan 14, 2025
1 parent d5a6ff5 commit ec10d7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .actions
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
hello_world = echo "Hello World"

# Build commands, will be used with github actions
build_win-x64 = GOOS=windows GOARCH=amd64 go build -o build/actionfile-win-x64.exe
build_win-x64 = GOOS=windows GOARCH=amd64 go build -o build/actionfile-win-x64.exe ## A comment here
build_linux-x64 = GOOS=linux GOARCH=amd64 go build -o build/actionfile-linux-x64
build_linux-arm64 = GOOS=linux GOARCH=arm64 go build -o build/actionfile-linux-arm64
build_mac-x64 = GOOS=darwin GOARCH=amd64 go build -o build/actionfile-mac-x64
Expand Down
12 changes: 9 additions & 3 deletions utils/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

var ConfigFileName string = ".actions"
var CurrentVersion string = "0.1.22"
var CurrentVersion string = "0.1.24"

type CommandsArray struct {
Name string
Expand Down Expand Up @@ -40,20 +40,26 @@ func LoadCommands() []CommandsArray {
// Parse each line
for _, line := range strings.Split(string(data), "\n") {
line = strings.TrimSpace(line)
if len(line) == 0 || strings.Contains(line, "#") {
if len(line) == 0 || strings.HasPrefix(line, "#") {
continue
}

// Split by = first
parts := strings.SplitN(line, "=", 2)

if len(parts) != 2 && !strings.Contains(line, "#") {
if len(parts) != 2 {
Logger(LoggerOptions{Level: "warn", Message: fmt.Sprintf("Invalid line format: %s", line)})
continue
}

cmdName := strings.TrimSpace(parts[0])
cmdString := strings.TrimSpace(parts[1])

// Remove comments from command string
if commentIndex := strings.Index(cmdString, "#"); commentIndex != -1 {
cmdString = strings.TrimSpace(cmdString[:commentIndex])
}

if cmdName == "" || cmdString == "" {
Logger(LoggerOptions{Level: "warn", Message: fmt.Sprintf("Empty command name or string: %s", line)})
continue
Expand Down

0 comments on commit ec10d7e

Please sign in to comment.