Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
)

func NewCommad() *cobra.Command {
func NewCommand() *cobra.Command {

var clientOpts connectors.ClientOptions

Expand Down
11 changes: 6 additions & 5 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command
}
}

// Normalize file path to match the watcher fsnotify events format.
if strings.HasPrefix(f, "./") {
f = strings.TrimPrefix(f, "./")
}
Comment on lines +134 to +137
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is that [string.HasPrefix(f,"./")] only matches POSIX ./ . it misses Windows .\ and doesn't normalize segments like foo/../bar or duplicate slashes so the fsnotify and other file APIs may produce paths with different separators or redundant segments. to fix this use [filepath.Clean] (OS-aware normalization) then trim a leading . + path separator.


// Try uploading this artifact.
msg, err := mc.UploadArtifact(f, mainArtifact)
if err != nil {
Expand All @@ -154,10 +159,6 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command
watchCfg = &config.WatchConfig{}
}

// Normalize file path to match the watcher fsnotify events format.
if strings.HasPrefix(f, "./") {
f = strings.TrimPrefix(f, "./")
}

// Upsert entry.
watchCfg.UpsertEntry(config.WatchEntry{
Expand All @@ -177,7 +178,7 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command
watchFile, err := config.DefaultLocalWatchPath()
errors.CheckError(err)

wm, err := watcher.NewWatchManger(watchFile)
wm, err := watcher.NewWatchManager(watchFile)
errors.CheckError(err)

fmt.Println("Watch mode enabled - microcks-watcher started...")
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func main() {
command := cmd.NewCommad()
command := cmd.NewCommand()
if err := command.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion pkg/watcher/watchManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type WatchManager struct {
lock sync.Mutex
}

func NewWatchManger(configPath string) (*WatchManager, error) {
func NewWatchManager(configPath string) (*WatchManager, error) {
fw, err := fsnotify.NewWatcher()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func main() {
watchFile, err := config.DefaultLocalWatchPath()
errors.CheckError(err)

wm, err := watcher.NewWatchManger(watchFile)
wm, err := watcher.NewWatchManager(watchFile)
errors.CheckError(err)

fmt.Println("[INFO] microcks-watcher started...")
Expand Down