MCPcopy
hub / github.com/revel/revel / addModule

Function addModule

module.go:171–201  ·  view source on GitHub ↗

called by `loadModules`, creates a new `Module` instance and appends it to the `Modules` list.

(name, importPath, modulePath string)

Source from the content-addressed store, hash-verified

169
170// called by `loadModules`, creates a new `Module` instance and appends it to the `Modules` list.
171func addModule(name, importPath, modulePath string) {
172 if _, found := ModuleByName(name); found {
173 moduleLog.Panic("Attempt to import duplicate module %s path %s aborting startup", "name", name, "path", modulePath)
174 }
175 Modules = append(Modules, &Module{
176 Name: name,
177 ImportPath: filepath.ToSlash(importPath),
178 Path: filepath.ToSlash(modulePath),
179 Log: RootLog.New("module", name),
180 })
181 if codePath := filepath.Join(modulePath, "app"); DirExists(codePath) {
182 CodePaths = append(CodePaths, codePath)
183 if viewsPath := filepath.Join(modulePath, "app", "views"); DirExists(viewsPath) {
184 TemplatePaths = append(TemplatePaths, viewsPath)
185 }
186 }
187
188 moduleLog.Debug("Loaded module ", "module", filepath.Base(modulePath))
189
190 // Hack: There is presently no way for the testrunner module to add the
191 // "test" subdirectory to the CodePaths. So this does it instead.
192 if importPath == Config.StringDefault("module.testrunner", "github.com/revel/modules/testrunner") {
193 joinedPath := filepath.Join(BasePath, "tests")
194 moduleLog.Debug("Found testrunner module, adding `tests` path ", "path", joinedPath)
195 CodePaths = append(CodePaths, joinedPath)
196 }
197 if testsPath := filepath.Join(modulePath, "tests"); DirExists(testsPath) {
198 moduleLog.Debug("Found tests path ", "path", testsPath)
199 CodePaths = append(CodePaths, testsPath)
200 }
201}

Callers 1

loadModulesFunction · 0.85

Calls 5

ModuleByNameFunction · 0.85
DirExistsFunction · 0.85
DebugMethod · 0.80
PanicMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected