mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Tool updates
Updated tool to give more meaningful errors Added file system as an option to fetch the skeleton from
This commit is contained in:
@@ -92,7 +92,7 @@ type (
|
||||
)
|
||||
|
||||
// Updates the import path depending on the command
|
||||
func (c *CommandConfig) UpdateImportPath() bool {
|
||||
func (c *CommandConfig) UpdateImportPath() error {
|
||||
var importPath string
|
||||
required := true
|
||||
switch c.Index {
|
||||
@@ -114,6 +114,7 @@ func (c *CommandConfig) UpdateImportPath() bool {
|
||||
}
|
||||
|
||||
if len(importPath) == 0 || filepath.IsAbs(importPath) || importPath[0] == '.' {
|
||||
utils.Logger.Info("Import path is absolute or not specified", "path", importPath)
|
||||
// Try to determine the import path from the GO paths and the command line
|
||||
currentPath, err := os.Getwd()
|
||||
if len(importPath) > 0 {
|
||||
@@ -135,7 +136,7 @@ func (c *CommandConfig) UpdateImportPath() bool {
|
||||
if len(importPath) > 4 && strings.ToLower(importPath[0:4]) == "src/" {
|
||||
importPath = importPath[4:]
|
||||
} else if importPath == "src" {
|
||||
importPath = ""
|
||||
return fmt.Errorf("Invlaid import path, working dir is in GOPATH root")
|
||||
}
|
||||
utils.Logger.Info("Updated import path", "path", importPath)
|
||||
}
|
||||
@@ -155,7 +156,13 @@ func (c *CommandConfig) UpdateImportPath() bool {
|
||||
}
|
||||
utils.Logger.Info("Revel versions", "revel-tool", c.CommandVersion.String(), "Revel Framework", c.FrameworkVersion.String())
|
||||
}
|
||||
return (len(importPath) > 0 || !required)
|
||||
if !required {
|
||||
return nil
|
||||
}
|
||||
if len(importPath) == 0 {
|
||||
return fmt.Errorf("Unable to determine import path from : %s", importPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Used to initialize the package resolver
|
||||
|
||||
@@ -120,8 +120,16 @@ func NewRevelPaths(mode, importPath, srcPath string, callback RevelCallback) (rp
|
||||
rp.BasePath = filepath.Join(rp.SourcePath, filepath.FromSlash(importPath))
|
||||
rp.PackageInfo.Vendor = utils.Exists(filepath.Join(rp.BasePath, "vendor"))
|
||||
rp.AppPath = filepath.Join(rp.BasePath, "app")
|
||||
rp.ViewsPath = filepath.Join(rp.AppPath, "views")
|
||||
|
||||
// Sanity check , ensure app and conf paths exist
|
||||
if !utils.DirExists(rp.AppPath) {
|
||||
return rp, fmt.Errorf("No application found at path %s", rp.AppPath)
|
||||
}
|
||||
if !utils.DirExists(filepath.Join(rp.BasePath, "conf")) {
|
||||
return rp, fmt.Errorf("No configuration found at path %s", filepath.Join(rp.BasePath, "conf"))
|
||||
}
|
||||
|
||||
rp.ViewsPath = filepath.Join(rp.AppPath, "views")
|
||||
rp.CodePaths = []string{rp.AppPath}
|
||||
rp.TemplatePaths = []string{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user