mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-23 07:21:28 +00:00
Merge pull request #176 from xXLokerXx/fix_windows_path
acept slash and inverted slash in src path validation
This commit is contained in:
@@ -2,9 +2,6 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/revel/cmd"
|
|
||||||
"github.com/revel/cmd/logger"
|
|
||||||
"github.com/revel/cmd/utils"
|
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/build"
|
"go/build"
|
||||||
"go/parser"
|
"go/parser"
|
||||||
@@ -14,6 +11,10 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/revel/cmd"
|
||||||
|
"github.com/revel/cmd/logger"
|
||||||
|
"github.com/revel/cmd/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The constants
|
// The constants
|
||||||
@@ -44,7 +45,7 @@ type (
|
|||||||
SrcRoot string // The source root
|
SrcRoot string // The source root
|
||||||
AppPath string // The application path (absolute)
|
AppPath string // The application path (absolute)
|
||||||
AppName string // The application name
|
AppName string // The application name
|
||||||
Vendored bool // True if the application is vendored
|
Vendored bool // True if the application is vendored
|
||||||
PackageResolver func(pkgName string) error // a packge resolver for the config
|
PackageResolver func(pkgName string) error // a packge resolver for the config
|
||||||
BuildFlags []string `short:"X" long:"build-flags" description:"These flags will be used when building the application. May be specified multiple times, only applicable for Build, Run, Package, Test commands"`
|
BuildFlags []string `short:"X" long:"build-flags" description:"These flags will be used when building the application. May be specified multiple times, only applicable for Build, Run, Package, Test commands"`
|
||||||
// The new command
|
// The new command
|
||||||
@@ -134,7 +135,8 @@ func (c *CommandConfig) UpdateImportPath() error {
|
|||||||
if strings.HasPrefix(currentPath, path) && len(currentPath) > len(path)+1 {
|
if strings.HasPrefix(currentPath, path) && len(currentPath) > len(path)+1 {
|
||||||
importPath = currentPath[len(path)+1:]
|
importPath = currentPath[len(path)+1:]
|
||||||
// Remove the source from the path if it is there
|
// Remove the source from the path if it is there
|
||||||
if len(importPath) > 4 && strings.ToLower(importPath[0:4]) == "src/" {
|
isSRC := strings.ToLower(importPath[0:4])
|
||||||
|
if len(importPath) > 4 && (isSRC == "src/" || isSRC == "src\\") {
|
||||||
importPath = importPath[4:]
|
importPath = importPath[4:]
|
||||||
} else if importPath == "src" {
|
} else if importPath == "src" {
|
||||||
if c.Index != VERSION {
|
if c.Index != VERSION {
|
||||||
@@ -154,7 +156,7 @@ func (c *CommandConfig) UpdateImportPath() error {
|
|||||||
if err := c.SetVersions(); err != nil {
|
if err := c.SetVersions(); err != nil {
|
||||||
utils.Logger.Panic("Failed to fetch revel versions", "error", err)
|
utils.Logger.Panic("Failed to fetch revel versions", "error", err)
|
||||||
}
|
}
|
||||||
if err:=c.FrameworkVersion.CompatibleFramework(c);err!=nil {
|
if err := c.FrameworkVersion.CompatibleFramework(c); err != nil {
|
||||||
utils.Logger.Fatal("Compatibility Error", "message", err,
|
utils.Logger.Fatal("Compatibility Error", "message", err,
|
||||||
"Revel framework version", c.FrameworkVersion.String(), "Revel tool version", c.CommandVersion.String())
|
"Revel framework version", c.FrameworkVersion.String(), "Revel tool version", c.CommandVersion.String())
|
||||||
}
|
}
|
||||||
@@ -163,7 +165,7 @@ func (c *CommandConfig) UpdateImportPath() error {
|
|||||||
if !required {
|
if !required {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(importPath) == 0 {
|
if len(importPath) == 0 {
|
||||||
return fmt.Errorf("Unable to determine import path from : %s", importPath)
|
return fmt.Errorf("Unable to determine import path from : %s", importPath)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -219,7 +221,6 @@ func (c *CommandConfig) InitPackageResolver() {
|
|||||||
getCmd = exec.Command(depPath, "ensure", "-update", pkgName)
|
getCmd = exec.Command(depPath, "ensure", "-update", pkgName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
utils.Logger.Info("No vendor folder detected, not using dependency manager to import package", "package", pkgName)
|
utils.Logger.Info("No vendor folder detected, not using dependency manager to import package", "package", pkgName)
|
||||||
getCmd = exec.Command(c.GoCmd, "get", "-u", pkgName)
|
getCmd = exec.Command(c.GoCmd, "get", "-u", pkgName)
|
||||||
@@ -275,7 +276,7 @@ func (c *CommandConfig) InitGoPaths() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.Logger.Info("Source root", "path", c.SrcRoot, "cwd", workingDir, "gopath", c.GoPath, "bestpath",bestpath)
|
utils.Logger.Info("Source root", "path", c.SrcRoot, "cwd", workingDir, "gopath", c.GoPath, "bestpath", bestpath)
|
||||||
if len(c.SrcRoot) == 0 && len(bestpath) > 0 {
|
if len(c.SrcRoot) == 0 && len(bestpath) > 0 {
|
||||||
c.SrcRoot = bestpath
|
c.SrcRoot = bestpath
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user