Adds a function to get the output path for files
This commit is contained in:
parent
f286816b98
commit
1621811d22
@ -17,6 +17,7 @@ package compiler
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/jjdekker/ponder/helpers"
|
"github.com/jjdekker/ponder/helpers"
|
||||||
@ -60,3 +61,14 @@ func compilePath(root string, opts *settings.Settings,
|
|||||||
return nil
|
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)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user