@@ -6,62 +6,6 @@ import (
66 "strings"
77)
88
9- func moduleCycleFromLoadStack (stack []string , next string ) ([]string , bool ) {
10- for idx , key := range stack {
11- if key == next {
12- cycle := append (append ([]string (nil ), stack [idx :]... ), next )
13- return cycle , true
14- }
15- }
16- return nil , false
17- }
18-
19- func moduleExecutionChain (stack []moduleContext ) []string {
20- chain := make ([]string , 0 , len (stack ))
21- for _ , ctx := range stack {
22- if ctx .key == "" {
23- continue
24- }
25- if len (chain ) > 0 && chain [len (chain )- 1 ] == ctx .key {
26- continue
27- }
28- chain = append (chain , ctx .key )
29- }
30- return chain
31- }
32-
33- func moduleCycleFromExecution (stack []moduleContext , next string ) ([]string , bool ) {
34- chain := moduleExecutionChain (stack )
35- if len (chain ) < 2 {
36- return nil , false
37- }
38- for idx , key := range chain [:len (chain )- 1 ] {
39- if key == next {
40- cycle := append (append ([]string (nil ), chain [idx :]... ), next )
41- return cycle , true
42- }
43- }
44- return nil , false
45- }
46-
47- func formatModuleCycle (cycle []string ) string {
48- if len (cycle ) == 0 {
49- return ""
50- }
51- normalized := make ([]string , 0 , len (cycle ))
52- for _ , key := range cycle {
53- if len (normalized ) > 0 && normalized [len (normalized )- 1 ] == key {
54- continue
55- }
56- normalized = append (normalized , key )
57- }
58- parts := make ([]string , len (normalized ))
59- for idx , key := range normalized {
60- parts [idx ] = moduleDisplayName (key )
61- }
62- return strings .Join (parts , " -> " )
63- }
64-
659func shouldExportModuleFunction (fn * ScriptFunction ) bool {
6610 return fn != nil && ! fn .Private
6711}
0 commit comments