Skip to content

current version doesn't work on windows #1

@hmbemba

Description

@hmbemba
proc newWatchout*(
  pattern: string,
  onChange: WatchCallback,
  onFound: WatchCallback,
  onDelete: WatchCallback = nil,
  delay: range[100..5000] = 350,
  recursive = false,
  browserSync: WatchoutBrowserSync = nil
): Watchout =
  result = Watchout(
    pattern: pattern,
    delay: delay,
    onChange: onChange,
    onFound: onFound,
    onDelete: onDelete,
    recursive: recursive,
    browserSync: browserSync
  )
  initLock(result.L) # 🔒 Ensure the lock is initialized on Windows


proc newWatchout*(
  dirs: seq[string],
  onChange: WatchCallback,
  onFound: WatchCallback,
  onDelete: WatchCallback = nil,
  delay: range[100..5000] = 350,
  recursive = false,
  ext: seq[string] = @[],
  browserSync: WatchoutBrowserSync = nil
): Watchout =
  result = Watchout(
    dirs: dirs,
    delay: delay,
    onChange: onChange,
    onFound: onFound,
    onDelete: onDelete,
    recursive: recursive,
    ext: ext,
    browserSync: browserSync
  )
  initLock(result.L) # 🔒 Fix for Windows uninitialized lock crash
proc start*(w: Watchout) =
  var thr: Thread[Watchout]
  createThread(thr, startThread, w)
  while true:
    sleep(1000) # keeps main thread alive

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions