File tree Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change 66 "os"
77 "os/exec"
88 "path/filepath"
9+ "sort"
910 "strings"
1011
1112 "golang.org/x/exp/maps"
@@ -62,9 +63,36 @@ func listScripts() []string {
6263 return empty
6364 }
6465 if pkg .Scripts == nil {
65- return empty
66+ pkg .Scripts = & map [string ]string {}
67+ }
68+
69+ // Add all executibles to the script list
70+ binDirs := findBinDirs (cwd )
71+ for _ , dir := range binDirs {
72+ files , err := os .ReadDir (dir )
73+ if err != nil {
74+ continue
75+ }
76+ for _ , file := range files {
77+ if file .IsDir () {
78+ continue
79+ }
80+ if _ , ok := (* pkg .Scripts )[file .Name ()]; ok {
81+ continue
82+ }
83+ info , err := os .Stat (filepath .Join (dir , file .Name ()))
84+ if err != nil {
85+ continue
86+ }
87+ if info .Mode ()& 0111 != 0 {
88+ (* pkg .Scripts )[file .Name ()] = ""
89+ }
90+ }
6691 }
67- return maps .Keys (* pkg .Scripts )
92+
93+ scripts := maps .Keys (* pkg .Scripts )
94+ sort .Strings (scripts )
95+ return scripts
6896}
6997
7098func resolveBinary (name string , binDirs []string ) (string , error ) {
You can’t perform that action at this time.
0 commit comments