MCPcopy
hub / github.com/cortesi/modd / runBlock

Method runBlock

modd.go:109–146  ·  view source on GitHub ↗
(b conf.Block, mod *moddwatch.Mod, dpen *DaemonPen)

Source from the content-addressed store, hash-verified

107}
108
109func (mr *ModRunner) runBlock(b conf.Block, mod *moddwatch.Mod, dpen *DaemonPen) {
110 if b.InDir != "" {
111 currentDir, err := os.Getwd()
112 if err != nil {
113 mr.Log.Shout("Error getting current working directory: %s", err)
114 return
115 }
116 err = os.Chdir(b.InDir)
117 if err != nil {
118 mr.Log.Shout(
119 "Error changing to indir directory \"%s\": %s",
120 b.InDir,
121 err,
122 )
123 return
124 }
125 defer func() {
126 err := os.Chdir(currentDir)
127 if err != nil {
128 mr.Log.Shout("Error returning to original directory: %s", err)
129 }
130 }()
131 }
132 err := RunPreps(
133 b,
134 mr.Config.GetVariables(),
135 mod, mr.Log,
136 mr.Notifiers,
137 mod == nil,
138 )
139 if err != nil {
140 if _, ok := err.(ProcError); !ok {
141 mr.Log.Shout("Error running prep: %s", err)
142 }
143 return
144 }
145 dpen.Restart()
146}
147
148func (mr *ModRunner) trigger(root string, mod *moddwatch.Mod, dworld *DaemonWorld) {
149 for i, b := range mr.Config.Blocks {

Callers 1

triggerMethod · 0.95

Calls 3

RunPrepsFunction · 0.85
GetVariablesMethod · 0.80
RestartMethod · 0.45

Tested by

no test coverage detected