Skip to content

Commit dbbd7b0

Browse files
committed
chore: configurable watch paths
1 parent fff15a3 commit dbbd7b0

3 files changed

Lines changed: 82 additions & 76 deletions

File tree

api/openapi.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,18 @@ components:
9696

9797
WatchModeRequest:
9898
type: object
99+
required: [watchPaths]
99100
properties:
100-
hotReloadCommands:
101+
watchPaths:
101102
type: array
102103
items:
103104
type: string
104-
description: Commands to run when files change
105-
buildCommands:
105+
description: Directories to watch
106+
hotReloadCommands:
106107
type: array
107108
items:
108109
type: string
109-
description: Build commands to run before hot reload
110+
description: Commands to run when files change
110111

111112
# Response Types
112113
TokenResponse:

internal/api/generated.go

Lines changed: 69 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/handler/watch_handler.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package handler
22

33
import (
44
"encoding/json"
5-
"path/filepath"
65
"time"
76

87
"github.com/gofiber/contrib/websocket"
@@ -35,7 +34,6 @@ func (udh *WatchHandler) EnableWatch(c *fiber.Ctx) error {
3534
return c.JSON(response)
3635
}
3736

38-
var watchPaths []string
3937
// Get current scroll to determine watch paths
4038
scrollDir := udh.scrollService.GetDir()
4139
if scrollDir == "" {
@@ -62,7 +60,14 @@ func (udh *WatchHandler) EnableWatch(c *fiber.Ctx) error {
6260
}
6361
}
6462

65-
watchPaths = append(watchPaths, filepath.Join(scrollDir, "public/src"), filepath.Join(scrollDir, "private/src"))
63+
watchPaths := requestBody.WatchPaths
64+
65+
if len(watchPaths) == 0 {
66+
return c.Status(400).JSON(api.ErrorResponse{
67+
Status: "error",
68+
Error: "At least one watch path must be specified",
69+
})
70+
}
6671

6772
// Start file watching with scroll directory as base path
6873
err = udh.uiWatchService.StartWatching(scrollDir, watchPaths...)

0 commit comments

Comments
 (0)