about summary refs log tree commit diff stats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/build/main.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/cmd/build/main.go b/cmd/build/main.go
index 81d31e9..ad905fd 100644
--- a/cmd/build/main.go
+++ b/cmd/build/main.go
@@ -402,6 +402,10 @@ func renderFeedStyles() (io.Reader, error) {
 	return strings.NewReader(doc.OutputXML(true)), nil
 }
 
+func mkdirp(dirs ...string) error {
+	return os.MkdirAll(path.Join(dirs...), 0755)
+}
+
 func outputToFile(output io.Reader, filename ...string) error {
 	file, err := os.OpenFile(path.Join(filename...), os.O_WRONLY|os.O_CREATE, 00644)
 	if err != nil {
@@ -421,7 +425,7 @@ func build() error {
 		return err
 	}
 	outDir := "new"
-	if err := os.MkdirAll(path.Join(outDir, "post"), 0755); err != nil {
+	if err := mkdirp(outDir, "post"); err != nil {
 		return errors.WithMessage(err, "could not create post output directory")
 	}
 	posts, tags, err := readPosts("content", "post", outDir)
@@ -430,9 +434,8 @@ func build() error {
 	}
 
 	for _, post := range posts {
-		dst := path.Join(outDir, "post", post.Basename)
-		if err := os.MkdirAll(dst, 0755); err != nil {
-			return errors.WithMessagef(err, "could not create directory for post %s", dst)
+		if err := mkdirp(outDir, "post", post.Basename); err != nil {
+			return errors.WithMessage(err, "could not create directory for post")
 		}
 		output, err := renderPost(post, *config)
 		if err != nil {
@@ -443,7 +446,7 @@ func build() error {
 		}
 	}
 
-	if err := os.MkdirAll(path.Join(outDir, "tags"), 0755); err != nil {
+	if err := mkdirp(outDir, "tags"); err != nil {
 		return errors.WithMessage(err, "could not create directory for tags")
 	}
 	output, err := renderTags(tags, *config)
@@ -461,7 +464,7 @@ func build() error {
 				matchingPosts = append(matchingPosts, post)
 			}
 		}
-		if err := os.MkdirAll(path.Join(outDir, "tags", tag), 0755); err != nil {
+		if err := mkdirp(outDir, "tags", tag); err != nil {
 			return errors.WithMessage(err, "could not create directory")
 		}
 		output, err := renderListPage(tag, *config, matchingPosts)