Skip to content

Feat/watch mode#80

Merged
YOU54F merged 5 commits intopact-foundation:masterfrom
YOU54F:feat/watch-mode
Oct 31, 2025
Merged

Feat/watch mode#80
YOU54F merged 5 commits intopact-foundation:masterfrom
YOU54F:feat/watch-mode

Conversation

@YOU54F
Copy link
Member

@YOU54F YOU54F commented Oct 23, 2025

Fixes #52

note includes #78 / #79

Introduces 2 new crates notify - CC0 & notify-debouncer-mini - MIT or Apache 2.0.

Should this be feature gated?

Watch mode

The Pact Stub Server now supports a watch mode that automatically monitors pact files and directories for changes and reloads them without restarting the server. This feature is particularly useful during development when pact files are frequently updated.

Usage

To enable watch mode, use the --watch or -w flag:

# Watch a single pact file
pact-stub-server --file path/to/pact.json --watch --port 8080

# Watch a directory of pact files
pact-stub-server --dir path/to/pacts --watch --port 8080

# Watch multiple files and directories
pact-stub-server --file pact1.json --file pact2.json --dir pacts_dir --watch --port 8080

Supported Source Types

Watch mode supports the following pact source types:

  • File sources (--file): Individual pact files are monitored for changes
  • Directory sources (--dir): Entire directories are monitored recursively for changes to pact files

Note: URL sources (--url) and Pact Broker sources (--broker-url) are not supported for watching as they are remote resources.

File System Events

The watcher responds to the following types of file system events:

  • File modifications (content changes)
  • File creation (new pact files added)
  • File deletion (pact files removed)
  • Directory changes (new files added to watched directories)

Limitations

  • Only works with local file and directory sources
  • URL and Pact Broker sources cannot be watched
  • Requires file system notifications to be available on the host system
  • Memory usage may be slightly higher due to shared state management

Testing

Run ./scripts/test_watch.sh and follow the instructions

It will

  1. Creates a pact file, in /tmp
  2. Starts the server

In another terminal,

  1. run: curl http://localhost:8080/test
  2. Modify the pact file and curl again to see changes

@YOU54F YOU54F mentioned this pull request Oct 24, 2025
@YOU54F YOU54F merged commit 45e0056 into pact-foundation:master Oct 31, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Live update stubs

1 participant