called by `loadModules`, creates a new `Module` instance and appends it to the `Modules` list.
(name, importPath, modulePath string)
| 169 | |
| 170 | // called by `loadModules`, creates a new `Module` instance and appends it to the `Modules` list. |
| 171 | func 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 | } |
no test coverage detected