Skip to content

Commit

Permalink
Create README for new SIGs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Hannaford committed Jun 12, 2017
1 parent 9f00b6b commit 65a7efc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions generator/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ func (slice SigEntries) Swap(i, j int) {
slice.Sigs[i], slice.Sigs[j] = slice.Sigs[j], slice.Sigs[i]
}

func createDirIfNotExists(path string) error {
func pathExists(path string) bool {
_, err := os.Stat(path)
if os.IsNotExist(err) {
return os.IsExist(err)
}

func createDirIfNotExists(path string) error {
if !pathExists(path) {
fmt.Printf("%s directory does not exist, creating\n", path)
return os.Mkdir(path, 0755)
}
Expand Down Expand Up @@ -134,6 +138,14 @@ func writeTemplate(templatePath, outputPath string, data interface{}) error {
return err
}

// create if not exists
if !pathExists(outputPath) {
_, err := os.Create(outputPath)
if err != nil {
return err
}
}

// open file and truncate
f, err := os.OpenFile(outputPath, os.O_RDWR, 0644)
if err != nil {
Expand Down

0 comments on commit 65a7efc

Please sign in to comment.