mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +00:00
fix
This commit is contained in:
parent
ccc29509df
commit
bacf94f3d5
1 changed files with 4 additions and 4 deletions
|
@ -93,7 +93,7 @@ func NewProjectFromPath(absPath string) *Project {
|
||||||
|
|
||||||
p := new(Project)
|
p := new(Project)
|
||||||
|
|
||||||
p.absPath = findCmdSuffix(absPath)
|
p.absPath = findCmdPath(absPath)
|
||||||
p.name = filepath.ToSlash(trimSrcPath(p.absPath, p.SrcPath()))
|
p.name = filepath.ToSlash(trimSrcPath(p.absPath, p.SrcPath()))
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
@ -131,13 +131,13 @@ func (p *Project) CmdPath() string {
|
||||||
return p.cmdPath
|
return p.cmdPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// findCmdSuffix returns the cmd dir start with file path separator.
|
// findCmdPath returns the cmd path.
|
||||||
func findCmdSuffix(path string) string {
|
func findCmdPath(path string) string {
|
||||||
cmdDir := findCmdDir(path)
|
cmdDir := findCmdDir(path)
|
||||||
if filepathHasPrefix(cmdDir, string(os.PathSeparator)) {
|
if filepathHasPrefix(cmdDir, string(os.PathSeparator)) {
|
||||||
return strings.TrimSuffix(path, cmdDir)
|
return strings.TrimSuffix(path, cmdDir)
|
||||||
}
|
}
|
||||||
return return strings.TrimSuffix(path, string(os.PathSeparator) + cmdDir)
|
return strings.TrimSuffix(path, string(os.PathSeparator)+cmdDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// findCmdDir checks if base of absPath is cmd dir and returns it or
|
// findCmdDir checks if base of absPath is cmd dir and returns it or
|
||||||
|
|
Loading…
Add table
Reference in a new issue