mirror of
https://github.com/danog/gojekyll.git
synced 2024-11-27 02:54:45 +01:00
40 lines
744 B
Go
40 lines
744 B
Go
|
package site
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"os"
|
||
|
"os/exec"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
func (s *Site) findTheme() error {
|
||
|
if s.config.Theme == "" {
|
||
|
return nil
|
||
|
}
|
||
|
exe, err := exec.LookPath("bundle")
|
||
|
if err != nil {
|
||
|
log.Fatal("bundle is not in your PATH", err)
|
||
|
}
|
||
|
cmd := exec.Command(exe, "show", s.config.Theme) // nolint: gas
|
||
|
cmd.Dir = s.AbsDir()
|
||
|
out, err := cmd.CombinedOutput()
|
||
|
if err != nil {
|
||
|
if os.IsNotExist(err) {
|
||
|
return fmt.Errorf("the %s theme could not be found", s.config.Theme)
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
s.themeDir = string(bytes.TrimSpace(out))
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (s *Site) readThemeAssets() error {
|
||
|
err := s.readFiles(filepath.Join(s.themeDir, "assets"), s.themeDir)
|
||
|
if os.IsNotExist(err) {
|
||
|
return nil
|
||
|
}
|
||
|
return err
|
||
|
}
|