mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-19 23:30:09 +08:00
fix #1309: locate plugin file upward recursively until system root dir
This commit is contained in:
@@ -1,9 +1,13 @@
|
|||||||
# Release History
|
# Release History
|
||||||
|
|
||||||
## v4.1.0 (2022-05-22)
|
## v4.1.0 (2022-05-23)
|
||||||
|
|
||||||
- feat: add `wiki` sub-command to open httprunner website
|
- feat: add `wiki` sub-command to open httprunner website
|
||||||
|
|
||||||
|
**go version**
|
||||||
|
|
||||||
|
- fix #1309: locate plugin file upward recursively until system root dir
|
||||||
|
|
||||||
## v4.1.0-beta (2022-05-21)
|
## v4.1.0-beta (2022-05-21)
|
||||||
|
|
||||||
- feat: add pre-commit-hook to format go/python code
|
- feat: add pre-commit-hook to format go/python code
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ func locatePlugin(path string) (pluginPath string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Warn().Err(err).Str("path", path).Msg("plugin file not found")
|
||||||
return "", fmt.Errorf("plugin file not found")
|
return "", fmt.Errorf("plugin file not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// locateFile searches destFile upward recursively until current
|
// locateFile searches destFile upward recursively until system root dir
|
||||||
// working directory or system root dir.
|
|
||||||
func locateFile(startPath string, destFile string) (string, error) {
|
func locateFile(startPath string, destFile string) (string, error) {
|
||||||
stat, err := os.Stat(startPath)
|
stat, err := os.Stat(startPath)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
@@ -103,12 +103,6 @@ func locateFile(startPath string, destFile string) (string, error) {
|
|||||||
return pluginPath, nil
|
return pluginPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// current working directory
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
if startDir == cwd {
|
|
||||||
return "", fmt.Errorf("searched to CWD, plugin file not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
// system root dir
|
// system root dir
|
||||||
parentDir, _ := filepath.Abs(filepath.Dir(startDir))
|
parentDir, _ := filepath.Abs(filepath.Dir(startDir))
|
||||||
if parentDir == startDir {
|
if parentDir == startDir {
|
||||||
|
|||||||
Reference in New Issue
Block a user