From 8578dc00d9a1b28e8c090f097d35830d6eaa50f4 Mon Sep 17 00:00:00 2001 From: Michael Rykov Date: Tue, 11 Jul 2017 14:04:42 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=9Cinit=E2=80=9D=20for=20an=20exist?= =?UTF-8?q?ing=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/new.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/new.go b/cmd/new.go index 5971cc5..ef1acd6 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -118,8 +118,12 @@ var newProjectCmd = &cobra.Command{ path, err := filepath.Abs(path) if err != nil { return err - } else if ok, _ := afero.Exists(mail.AppFs, path); ok { - return newUserError("%s already exists", path) + } + + // Check for config to see if a project exists + configPath := filepath.Join(path, "config.toml") + if ok, _ := afero.Exists(mail.AppFs, configPath); ok { + return newUserError("%s already contains a project", path) } // Create project directories @@ -130,7 +134,6 @@ var newProjectCmd = &cobra.Command{ } // Write basic configuration - configPath := filepath.Join(path, "config.toml") if err := writeTemplate(configPath, configTemplate, nil, true); err != nil { return err }