Skip to content

Commit

Permalink
Add dart_sass_embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Mar 9, 2022
1 parent 8db7a28 commit 0ab443f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
31 changes: 23 additions & 8 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ const (
// aliases is a map of known project aliases
// to make finding project more easy.
var aliases = map[string]string{
"hugo": "gohugoio/hugo",
"gutenberg": "keats/gutenberg",
"zola": "getzola/zola",
"hugo": "gohugoio/hugo",
"gutenberg": "keats/gutenberg",
"zola": "getzola/zola",
"dart_sass_embedded": "sass/dart-sass-embedded",
}

type template struct {
Range string
Tarball string
Bin string
Range string
Tarball string
Bin string
CleanVersion bool
}

type templates map[string][]template
Expand Down Expand Up @@ -73,8 +75,20 @@ type Project struct {

// URL returns the URL to download the tarball from.
func (p *Project) URL() string {
tarballName := fmt.Sprintf(p.template.Tarball, p.Name, p.cleanVersion)
return fmt.Sprintf(tarballTemplate, p.FullName, p.Version, tarballName)
var tarballName string
// All have version in the template, most have name.
if strings.Count(p.template.Tarball, "%s") == 1 {
tarballName = fmt.Sprintf(p.template.Tarball, p.cleanVersion)
} else {
tarballName = fmt.Sprintf(p.template.Tarball, p.Name, p.cleanVersion)
}

version := p.Version
if p.template.CleanVersion {
version = p.cleanVersion
}

return fmt.Sprintf(tarballTemplate, p.FullName, version, tarballName)
}

// BinaryName returns the name of the binary to look for
Expand Down Expand Up @@ -118,6 +132,7 @@ func (c *Cache) newProject(name, versionString string) (*Project, error) {

var t *template
projectTemplates, ok := c.templates[nwo[1]]

if ok {
for _, tmpl := range projectTemplates {
constraint, err := version.NewConstraint(tmpl.Range)
Expand Down
2 changes: 1 addition & 1 deletion statik/statik.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions templates/templates.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ gutenberg = [
zola = [
{ range = ">=0.5.0", tarball = "%s-v%s-x86_64-unknown-linux-gnu.tar.gz", bin = "zola" }
]

dart-sass-embedded = [
{ range = ">=1.49.4", tarball = "sass_embedded-%s-linux-x64.tar.gz", bin = "dart_sass_embedded", cleanVersion = true }
]

0 comments on commit 0ab443f

Please sign in to comment.