<commit_before>package devd

import (
	"os"
	"time"

	"github.com/cortesi/devd/livereload"
	"github.com/cortesi/moddwatch"
	"github.com/cortesi/termlog"
)

const batchTime = time.Millisecond * 200

// Watch watches an endpoint for changes, if it supports them.
func (r Route) Watch(ch chan []string, excludePatterns []string, log termlog.Logger) error {
	wd, err := os.Getwd()
	if err != nil {
		return err
	}
	switch r.Endpoint.(type) {
	case *filesystemEndpoint:
		ep := *r.Endpoint.(*filesystemEndpoint)
		modchan := make(chan *moddwatch.Mod, 1)
		_, err := moddwatch.Watch(
			wd,
			[]string{ep.Root + "/..."},
			excludePatterns,
			batchTime,
			modchan,
		)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				if !mod.Empty() {<commit_msg>Fix live reloading for linux.<commit_after>package devd

import (
	"os"
	"time"

	"github.com/cortesi/devd/livereload"
	"github.com/cortesi/moddwatch"
	"github.com/cortesi/termlog"
)

const batchTime = time.Millisecond * 200

// Watch watches an endpoint for changes, if it supports them.
func (r Route) Watch(ch chan []string, excludePatterns []string, log termlog.Logger) error {
	wd, err := os.Getwd()
	if err != nil {
		return err
	}
	switch r.Endpoint.(type) {
	case *filesystemEndpoint:
		ep := *r.Endpoint.(*filesystemEndpoint)
		modchan := make(chan *moddwatch.Mod, 1)
		_, err := moddwatch.Watch(
			wd,
			[]string{ep.Root + "/...", "**"},
			excludePatterns,
			batchTime,
			modchan,
		)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				if !mod.Empty() {
{'fraction_non_alphanumeric': 0.14810126582278482, 'fraction_numerical': 0.005063291139240506, 'mean_word_length': 3.355371900826446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4948859', 'n_tokens_mistral': 646, 'n_tokens_neox': 580, 'n_words': 146}