Some more error fixes in commands
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 2 Dec 2015 15:27:08 +0000 (16:27 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 2 Dec 2015 15:27:08 +0000 (16:27 +0100)
See #1502

commands/new.go

index 579d12a52a99b8ae6b85df9b17ed64b80f05e5ec..da2588fb4a6c41722310c3d857a1c96e3df2fd10 100644 (file)
@@ -176,7 +176,7 @@ func NewTheme(cmd *cobra.Command, args []string) error {
        jww.INFO.Println("creating theme at", createpath)
 
        if x, _ := helpers.Exists(createpath, hugofs.SourceFs); x {
-               jww.FATAL.Fatalln(createpath, "already exists")
+               return newUserError(createpath, "already exists")
        }
 
        mkdir(createpath, "layouts", "_default")
@@ -196,8 +196,7 @@ func NewTheme(cmd *cobra.Command, args []string) error {
 
        err := helpers.WriteToDisk(filepath.Join(createpath, "archetypes", "default.md"), bytes.NewReader(archDefault), hugofs.SourceFs)
        if err != nil {
-
-               jww.FATAL.Fatalln(err)
+               return err
        }
 
        mkdir(createpath, "static", "js")
@@ -227,7 +226,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
        err = helpers.WriteToDisk(filepath.Join(createpath, "LICENSE.md"), bytes.NewReader(by), hugofs.SourceFs)
        if err != nil {
-               return nil
+               return err
        }
 
        createThemeMD(createpath)