MCPcopy Create free account
hub / github.com/ddev/ddev / GetRelativeDirectory

Method GetRelativeDirectory

pkg/ddevapp/utils.go:504–513  ·  view source on GitHub ↗

GetRelativeDirectory returns the directory relative to project root Note that the relative dir is returned as unix-style forward-slashes

(targetPath string)

Source from the content-addressed store, hash-verified

502// GetRelativeDirectory returns the directory relative to project root
503// Note that the relative dir is returned as unix-style forward-slashes
504func (app *DdevApp) GetRelativeDirectory(targetPath string) string {
505 // Find the relative dir
506 relativeWorkingDir := strings.TrimPrefix(targetPath, app.AppRoot)
507 // Convert to slash/linux/macos notation, should work everywhere
508 relativeWorkingDir = filepath.ToSlash(relativeWorkingDir)
509 // Remove any leading /
510 relativeWorkingDir = strings.TrimLeft(relativeWorkingDir, "/")
511
512 return relativeWorkingDir
513}
514
515// GetRelativeWorkingDirectory returns the relative working directory relative to project root
516// Note that the relative dir is returned as unix-style forward-slashes

Calls

no outgoing calls

Tested by

no test coverage detected