modRelPath returns the relative path to a module's root dir from workdir If the target module is on a different source/context, the absolute ref is returned instead.
(def *moduleDef)
| 581 | // If the target module is on a different source/context, the absolute ref |
| 582 | // is returned instead. |
| 583 | func (h *shellCallHandler) modRelPath(def *moduleDef) string { |
| 584 | if srcRoot, _ := h.contextModRef(def.SourceRootSubpath); srcRoot == def.SourceRoot { |
| 585 | // use relative path if it's shorter |
| 586 | path, err := filepath.Rel(h.workdirAbsPath(), def.SourceRootSubpath) |
| 587 | if err == nil { |
| 588 | if len(path) > len(def.SourceRootSubpath) { |
| 589 | path = def.SourceRootSubpath |
| 590 | } |
| 591 | return path |
| 592 | } |
| 593 | } |
| 594 | return def.SourceRoot |
| 595 | } |
| 596 | |
| 597 | // IsDefaultModule returns true if the given module reference points to |
| 598 | // the current context's module |
no test coverage detected