Skip to content

Commit e095bd6

Browse files
committed
fix path issue
1 parent ae693ec commit e095bd6

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.goreleaser.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ builds:
1717
ldflags:
1818
- -s -w
1919
- -X main.Version={{.Version}}
20+
- -X main.TemplatesPath={{.TemplatesPath}}
2021
main: ./cmd/mcptools/main.go
2122

2223
archives:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ check-go:
2020

2121
build:
2222
@echo "$(YELLOW)Building $(BINARY_NAME)...$(NC)"
23-
go build -ldflags "-X main.Version=$(VERSION)" -o bin/$(BINARY_NAME) ./cmd/mcptools
23+
go build -ldflags "-X main.Version=$(VERSION) -X main.TemplatesPath=$(HOME)/.mcpt/templates" -o bin/$(BINARY_NAME) ./cmd/mcptools
2424

2525
install-templates:
2626
mkdir -p $(HOME)/.mcpt/templates

cmd/mcptools/commands/new.go

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/spf13/cobra"
1111
)
1212

13+
var TemplatesPath string = os.Getenv("HOME") + "/.mcpt/templates"
14+
1315
// Constants for template options.
1416
const (
1517
sdkTypeScript = "ts"
@@ -268,6 +270,9 @@ func findTemplatesDir(sdk string) string {
268270
// User home directory
269271
filepath.Join(os.Getenv("HOME"), ".mcpt", "templates", sdk),
270272

273+
// TemplatesPath from env
274+
TemplatesPath,
275+
271276
// Executable directory
272277
func() string {
273278
execPath, err := os.Executable()

cmd/mcptools/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import (
1212

1313
// version information placeholders.
1414
var (
15-
Version = "dev"
15+
Version = "dev"
16+
TemplatesPath = os.Getenv("HOME") + "/.mcpt/templates"
1617
)
1718

1819
func init() {
1920
commands.Version = Version
21+
commands.TemplatesPath = TemplatesPath
2022
}
2123

2224
func main() {

0 commit comments

Comments
 (0)