Creates a git ignore file when issueing the init command
This commit is contained in:
parent
8f54e99bf2
commit
8c02d6a954
11
cmd/init.go
11
cmd/init.go
@ -32,6 +32,8 @@ var (
|
|||||||
"LilypondIncludes": [],
|
"LilypondIncludes": [],
|
||||||
"OutputDir": "out"
|
"OutputDir": "out"
|
||||||
}`)
|
}`)
|
||||||
|
gitIgnoreTemplate = []byte(`# Output Folder
|
||||||
|
out/`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// initCmd represents the init command
|
// initCmd represents the init command
|
||||||
@ -73,12 +75,11 @@ func initializePath(path string) {
|
|||||||
helpers.Check(err, "Could not create directory")
|
helpers.Check(err, "Could not create directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
createSettings(path)
|
createFile(filepath.Join(path, settingsFile), settingsTemplate)
|
||||||
// createGitIgnore()
|
createFile(filepath.Join(path, ".gitignore"), gitIgnoreTemplate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createSettings(path string) {
|
func createFile(path string, content []byte) {
|
||||||
path = filepath.Join(path, settingsFile)
|
|
||||||
b, err := helpers.Exists(path)
|
b, err := helpers.Exists(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithFields(log.Fields{"error": err, "path": path}).
|
log.WithFields(log.Fields{"error": err, "path": path}).
|
||||||
@ -86,7 +87,7 @@ func createSettings(path string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !b {
|
if !b {
|
||||||
err = ioutil.WriteFile(path, settingsTemplate, 0644)
|
err = ioutil.WriteFile(path, content, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithFields(log.Fields{"error": err, "path": path}).
|
log.WithFields(log.Fields{"error": err, "path": path}).
|
||||||
Fatal("Unable to create settings file")
|
Fatal("Unable to create settings file")
|
||||||
|
Reference in New Issue
Block a user