MCPcopy Index your code
hub / github.com/dagger/dagger / modRelPath

Method modRelPath

cmd/dagger/shell_fs.go:583–595  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

581// If the target module is on a different source/context, the absolute ref
582// is returned instead.
583func (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

Callers 3

debugLoadedModulesMethod · 0.95
LoadedModulePathsMethod · 0.95
FunctionUseLineMethod · 0.95

Calls 2

contextModRefMethod · 0.95
workdirAbsPathMethod · 0.95

Tested by

no test coverage detected