File tree 1 file changed +30
-2
lines changed
1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change 6
6
"os"
7
7
"os/exec"
8
8
"path/filepath"
9
+ "sort"
9
10
"strings"
10
11
11
12
"golang.org/x/exp/maps"
@@ -62,9 +63,36 @@ func listScripts() []string {
62
63
return empty
63
64
}
64
65
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
+ }
66
91
}
67
- return maps .Keys (* pkg .Scripts )
92
+
93
+ scripts := maps .Keys (* pkg .Scripts )
94
+ sort .Strings (scripts )
95
+ return scripts
68
96
}
69
97
70
98
func resolveBinary (name string , binDirs []string ) (string , error ) {
You can’t perform that action at this time.
0 commit comments