From cfa2cb96172cda7ab153244140912d3af3021122 Mon Sep 17 00:00:00 2001 From: xucong053 Date: Thu, 26 May 2022 17:39:11 +0800 Subject: [PATCH] fix: failed to locate root dir even if proj.json exist --- hrp/plugin.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hrp/plugin.go b/hrp/plugin.go index 67a86cfe..f9465a90 100644 --- a/hrp/plugin.go +++ b/hrp/plugin.go @@ -17,6 +17,7 @@ const ( goPluginFile = "debugtalk.so" // built from go plugin hashicorpGoPluginFile = "debugtalk.bin" // built from hashicorp go plugin hashicorpPyPluginFile = "debugtalk.py" // used for hashicorp python plugin + projectInfoFile = "proj.json" // used for ensuring root project ) func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, pluginDir string, err error) { @@ -118,9 +119,15 @@ func GetProjectRootDirPath(path string) (rootDir string, err error) { rootDir = filepath.Dir(pluginPath) return } + // fix: no debugtalk file in project but having proj.json created by startpeoject + projPath, err := locateFile(path, projectInfoFile) + if err == nil { + rootDir = filepath.Dir(projPath) + return + } // failed to locate project root dir - // maybe project plugin debugtalk.xx is not exist + // maybe project plugin debugtalk.xx and proj.json are not exist // use current dir instead return os.Getwd() }