mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-21 14:45:02 +00:00
Amended importPathFromPath to detect vendor folder from basePath, not just the word vendor in the path
This commit is contained in:
@@ -60,9 +60,10 @@ func addImports(imports map[string]string, decl ast.Decl, srcDir string) {
|
|||||||
|
|
||||||
// Returns a valid import string from the path
|
// Returns a valid import string from the path
|
||||||
// using the build.Defaul.GOPATH to determine the root
|
// using the build.Defaul.GOPATH to determine the root
|
||||||
func importPathFromPath(root string) string {
|
func importPathFromPath(root, basePath string) string {
|
||||||
if vendorIdx := strings.Index(root, "/vendor/"); vendorIdx != -1 {
|
vendorTest := filepath.Join(basePath, "vendor")
|
||||||
return filepath.ToSlash(root[vendorIdx+8:])
|
if len(root) > len(vendorTest) && root[:len(vendorTest)] == vendorTest {
|
||||||
|
return filepath.ToSlash(root[len(vendorTest)+1:])
|
||||||
}
|
}
|
||||||
for _, gopath := range filepath.SplitList(build.Default.GOPATH) {
|
for _, gopath := range filepath.SplitList(build.Default.GOPATH) {
|
||||||
srcPath := filepath.Join(gopath, "src")
|
srcPath := filepath.Join(gopath, "src")
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ type methodMap map[string][]*model.MethodSpec
|
|||||||
func ProcessSource(paths *model.RevelContainer) (_ *model.SourceInfo, compileError error) {
|
func ProcessSource(paths *model.RevelContainer) (_ *model.SourceInfo, compileError error) {
|
||||||
pc := &processContainer{paths: paths}
|
pc := &processContainer{paths: paths}
|
||||||
for _, root := range paths.CodePaths {
|
for _, root := range paths.CodePaths {
|
||||||
rootImportPath := importPathFromPath(root)
|
rootImportPath := importPathFromPath(root, paths.BasePath)
|
||||||
if rootImportPath == "" {
|
if rootImportPath == "" {
|
||||||
utils.Logger.Info("Skipping empty code path", "path", root)
|
utils.Logger.Info("Skipping empty code path", "path", root)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user