Skip to content

Commit

Permalink
made version updatable in one place
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Jan de Wit <[email protected]>
  • Loading branch information
edewit committed Sep 17, 2024
1 parent 3172403 commit 4b36c2c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Platform Makefile
##

VERSION=0.23.0-mvnpm-0.0.8
VERSION=$(shell cat version.txt)
SASS_VERSION=1.78.0

platform-all:
Expand Down
16 changes: 10 additions & 6 deletions esbuild_scss.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ import (
"github.com/bep/godartsass/v2"
"github.com/evanw/esbuild/pkg/api"
"github.com/evanw/esbuild/pkg/cli"

_ "embed"
)

type NodeModulesImportResolver struct{
//go:embed version.txt
var version string
type NodeModulesImportResolver struct {
build api.PluginBuild
}

func (resolver NodeModulesImportResolver) CanonicalizeURL(url string) (string, error) {
var filePath = url
if strings.HasSuffix(url, "scss") {
result := resolver.build.Resolve(url, api.ResolveOptions{
Kind: api.ResolveCSSImportRule,
ResolveDir: ".",
})
Kind: api.ResolveCSSImportRule,
ResolveDir: ".",
})
filePath = result.Path
} else {
packagePath, fileName := filepath.Split(url)
Expand Down Expand Up @@ -95,7 +99,7 @@ func compileSass(inputPath, outputPath string, build api.PluginBuild) (string, e
SourceSyntax: sourceSyntax,
IncludePaths: []string{filepath.Dir(inputPath)},
EnableSourceMap: true,
ImportResolver: NodeModulesImportResolver{
ImportResolver: NodeModulesImportResolver{
build,
},
})
Expand Down Expand Up @@ -145,7 +149,7 @@ func main() {
for _, arg := range osArgs {
switch {
case arg == "--version":
fmt.Printf("0.20.1-mvnpm-0.0.7")
fmt.Printf("%s", version)
os.Exit(0)
case arg == "--watch" || arg == "--watch=forever":
go func() {
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.23.0-mvnpm-0.0.8

0 comments on commit 4b36c2c

Please sign in to comment.