Skip to content

Commit 6f51de3

Browse files
committed
Generate TypeScript event definitions into correct directory
1 parent fb6f3eb commit 6f51de3

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

cmd/new.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,13 @@ func newClient() error {
200200
return err
201201
}
202202

203-
eventsOutput := "."
204-
if language == "go" {
205-
eventsOutput = strings.ReplaceAll(strings.ReplaceAll(info.Name, "-", ""), "_", "")
206-
}
207-
208203
if language == "go" || language == "ts" {
204+
eventsOutput := info.Name
205+
if language == "go" {
206+
eventsOutput = strings.ReplaceAll(strings.ReplaceAll(eventsOutput, "-", ""), "_", "")
207+
} else if language == "ts" {
208+
eventsOutput = filepath.Join("src", eventsOutput)
209+
}
209210
err = cggenevents.CGGenEvents(cgeVersion, eventsOutput, external.BaseURL("http", external.IsTLS(url), url), language)
210211
if err != nil {
211212
return err

cmd/update.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
67
"strings"
78

89
"github.com/code-game-project/go-utils/cgfile"
@@ -55,7 +56,6 @@ func update() error {
5556
default:
5657
return fmt.Errorf("Unknown project type: %s", data.Type)
5758
}
58-
5959
}
6060

6161
func updateClient(config *cgfile.CodeGameFileData) error {
@@ -94,12 +94,13 @@ func updateClient(config *cgfile.CodeGameFileData) error {
9494
return err
9595
}
9696

97-
eventsOutput := "."
98-
if config.Lang == "go" {
99-
eventsOutput = strings.ReplaceAll(strings.ReplaceAll(config.Game, "-", ""), "_", "")
100-
}
101-
10297
if config.Lang == "go" || config.Lang == "ts" {
98+
eventsOutput := config.Game
99+
if config.Lang == "go" {
100+
eventsOutput = strings.ReplaceAll(strings.ReplaceAll(eventsOutput, "-", ""), "_", "")
101+
} else if config.Lang == "ts" {
102+
eventsOutput = filepath.Join("src", eventsOutput)
103+
}
103104
err = cggenevents.CGGenEvents(cgeVersion, eventsOutput, api.BaseURL(), config.Lang)
104105
}
105106

0 commit comments

Comments
 (0)