From 54ce8d3699752eb6098ea32c15d0654c26ca26b7 Mon Sep 17 00:00:00 2001 From: Ari Seyhun Date: Sat, 16 Sep 2017 15:24:37 +0930 Subject: [PATCH 1/2] Remove abort with 'revel new' on empty directory If you use 'revel new ...' on an empty directory, revel will abort complaining the directory exists. With this commit, it will no longer abort if the directory is empty. --- revel/new.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/revel/new.go b/revel/new.go index c893fbd..f438402 100644 --- a/revel/new.go +++ b/revel/new.go @@ -148,9 +148,13 @@ func setApplicationPath(args []string) { importPath) } + appPath = filepath.Join(srcRoot, filepath.FromSlash(importPath)) + _, err = build.Import(importPath, "", build.FindOnly) if err == nil { - errorf("Abort: Import path %s already exists.\n", importPath) + if !empty(appPath) { + errorf("Abort: Import path %s already exists.\n", importPath) + } } revelPkg, err = build.Import(revel.RevelImportPath, "", build.FindOnly) @@ -158,7 +162,6 @@ func setApplicationPath(args []string) { errorf("Abort: Could not find Revel source code: %s\n", err) } - appPath = filepath.Join(srcRoot, filepath.FromSlash(importPath)) appName = filepath.Base(appPath) basePath = filepath.ToSlash(filepath.Dir(importPath)) From 3907c6575e703c53bcb52be3dd0bdb6c6252c0d5 Mon Sep 17 00:00:00 2001 From: Ari Seyhun Date: Sat, 23 Sep 2017 14:20:09 +0930 Subject: [PATCH 2/2] Clean code --- revel/new.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/revel/new.go b/revel/new.go index f438402..c47b147 100644 --- a/revel/new.go +++ b/revel/new.go @@ -151,10 +151,8 @@ func setApplicationPath(args []string) { appPath = filepath.Join(srcRoot, filepath.FromSlash(importPath)) _, err = build.Import(importPath, "", build.FindOnly) - if err == nil { - if !empty(appPath) { - errorf("Abort: Import path %s already exists.\n", importPath) - } + if err == nil && !empty(appPath) { + errorf("Abort: Import path %s already exists.\n", importPath) } revelPkg, err = build.Import(revel.RevelImportPath, "", build.FindOnly)