Merge pull request #707 from jamiehannaford/create-new

Create README file for new SIGs
This commit is contained in:
Christoph Blecker 2017-06-13 11:12:57 -07:00 committed by GitHub
commit 0d95ccef31
1 changed files with 14 additions and 2 deletions

View File

@ -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 {