Archived
1
0

Adds a function to get the output path for files

This commit is contained in:
Jip J. Dekker 2016-03-20 23:21:29 +01:00
parent f286816b98
commit 1621811d22

View File

@ -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)
}