From 8c02d6a954a1b7e7db0f372301f3bbaa45351872 Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Thu, 17 Mar 2016 16:33:37 +0100 Subject: [PATCH] Creates a git ignore file when issueing the init command --- cmd/init.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 70660b3..2342228 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -32,6 +32,8 @@ var ( "LilypondIncludes": [], "OutputDir": "out" }`) + gitIgnoreTemplate = []byte(`# Output Folder +out/`) ) // initCmd represents the init command @@ -73,12 +75,11 @@ func initializePath(path string) { helpers.Check(err, "Could not create directory") } - createSettings(path) - // createGitIgnore() + createFile(filepath.Join(path, settingsFile), settingsTemplate) + createFile(filepath.Join(path, ".gitignore"), gitIgnoreTemplate) } -func createSettings(path string) { - path = filepath.Join(path, settingsFile) +func createFile(path string, content []byte) { b, err := helpers.Exists(path) if err != nil { log.WithFields(log.Fields{"error": err, "path": path}). @@ -86,7 +87,7 @@ func createSettings(path string) { } if !b { - err = ioutil.WriteFile(path, settingsTemplate, 0644) + err = ioutil.WriteFile(path, content, 0644) if err != nil { log.WithFields(log.Fields{"error": err, "path": path}). Fatal("Unable to create settings file")