refactor(spec): seperate into small files

This commit is contained in:
verse91
2026-04-16 00:32:24 +07:00
parent db8b6ec91b
commit 3adc045c09
4 changed files with 397 additions and 396 deletions
+32
View File
@@ -0,0 +1,32 @@
package core
import (
"os"
"path/filepath"
)
var pathCmds = make(map[string]bool)
// scanExternalCommands populates pathCmds with system executables
func scanExternalCommands() {
scanPath()
}
// scanPath populates pathCmds with all executable files found in path environment variable
func scanPath() {
dirs := filepath.SplitList(os.Getenv("PATH"))
for _, dir := range dirs {
files, err := os.ReadDir(dir)
if err != nil {
continue
}
for _, f := range files {
if !f.IsDir() {
info, err := f.Info()
if err == nil && info.Mode()&0111 != 0 {
pathCmds[f.Name()] = true
}
}
}
}
}