diff options
| author | Christoph Blecker <admin@toph.ca> | 2017-06-13 11:12:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-13 11:12:57 -0700 |
| commit | 0d95ccef31c98e4215d6c5a288aa3ccee76c9a3d (patch) | |
| tree | 0ade27dd034bc61802879f25bda1250356818d89 /generator/app.go | |
| parent | 170c08859ff25a22566c5c005636cdaac5b07657 (diff) | |
| parent | 65a7efca8aa71d66a0cfae41afba0b2c6c91f784 (diff) | |
Merge pull request #707 from jamiehannaford/create-new
Create README file for new SIGs
Diffstat (limited to 'generator/app.go')
| -rw-r--r-- | generator/app.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/generator/app.go b/generator/app.go index 1ece9685..0e650199 100644 --- a/generator/app.go +++ b/generator/app.go @@ -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) } @@ -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 { |
