From 1621811d22dc0de0b7cebc7fcafef069076d3230 Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Sun, 20 Mar 2016 23:21:29 +0100 Subject: [PATCH] Adds a function to get the output path for files --- compiler/file_discovery.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/file_discovery.go b/compiler/file_discovery.go index 474b2ac..bc42582 100644 --- a/compiler/file_discovery.go +++ b/compiler/file_discovery.go @@ -17,6 +17,7 @@ package compiler import ( "os" "path/filepath" + "strings" log "github.com/Sirupsen/logrus" "github.com/jjdekker/ponder/helpers" @@ -60,3 +61,14 @@ func compilePath(root string, opts *settings.Settings, return nil } } + +// outputPath returns the path that the compiled file will take +func outputPath(source string, opts *settings.Settings) string { + file := filepath.Base(source) + dot := strings.LastIndex(file, ".") + if dot == -1 { + log.WithFields(log.Fields{"path": source}).Error("Unable to compute output path") + } + file = file[:dot] + "pdf" + return filepath.Join(opts.OutputDir, file) +}