Archived
1
0

Fixes output path generation for the compile command

This commit is contained in:
Jip J. Dekker 2016-04-13 19:20:08 +02:00
parent a72f9d02a6
commit e4664f6183
3 changed files with 12 additions and 7 deletions

View File

@ -36,19 +36,23 @@ func CompileDir(path string, opts *settings.Settings) {
filepath.Walk(path, compilePath(path, opts, collector)) filepath.Walk(path, compilePath(path, opts, collector))
PrepareLilypond(opts) PrepareLilypond(opts)
for _, score := range scores { for i := range scores {
score.GenerateOutputPath(opts) scores[i].GenerateOutputPath(opts)
if !helpers.Exists(score.OutputPath) || if !helpers.Exists(scores[i].OutputPath) ||
score.LastModified.After(helpers.LastModified(score.OutputPath)) { scores[i].LastModified.After(helpers.LastModified(scores[i].OutputPath)) {
msg, err := Lilypond(score.Path) msg, err := Lilypond(scores[i].Path)
if err != nil { if err != nil {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"message": msg, "message": msg,
"error": err, "error": err,
"score": score, "score": scores[i],
}).Warning("score failed to compile") }).Warning("score failed to compile")
} }
} else {
log.WithFields(log.Fields{
"score": scores[i],
}).Debug("skipping compilation")
} }
} }
} }

View File

@ -43,7 +43,7 @@ func compilePath(root string, opts *settings.Settings,
helpers.Check(err, "Unable to create relative Path") helpers.Check(err, "Unable to create relative Path")
for _, dir := range append(append(opts.IgnoreDirs, opts.LilypondIncludes...), opts.OutputDir) { for _, dir := range append(append(opts.IgnoreDirs, opts.LilypondIncludes...), opts.OutputDir) {
if relPath == dir || (filepath.IsAbs(dir) && path == dir) { if relPath == dir || (filepath.IsAbs(dir) && path == dir) {
log.WithFields(log.Fields{"path": path}).Debug("Ignoring directory") log.WithFields(log.Fields{"path": path}).Debug("ignoring directory")
return filepath.SkipDir return filepath.SkipDir
} }
} }

View File

@ -56,5 +56,6 @@ func Lilypond(path string) (string, error) {
"cmd": cmd, "cmd": cmd,
}).Info("compiling file using lilypond") }).Info("compiling file using lilypond")
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
log.Debug("finished compiling")
return string(out), err return string(out), err
} }