MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / watch

Method watch

src/index.ts:2135–2157  ·  view source on GitHub ↗

* Start watching for file changes and auto-syncing. * * Uses native OS file events (FSEvents on macOS, inotify on Linux 19+, * ReadDirectoryChangesW on Windows) with debouncing to avoid thrashing. * * @param options - Watch options (debounce delay, callbacks) * @returns true if wat

(options: WatchOptions = {})

Source from the content-addressed store, hash-verified

2133 * @returns true if watching started successfully
2134 */
2135 watch(options: WatchOptions = {}): boolean {
2136 if (this.watcher?.isActive()) return true;
2137
2138 this.watcher = new (engine().FileWatcher)(
2139 this.projectRoot,
2140 async (paths?: string[]) => {
2141 const result = await this.sync({ paths });
2142 const filesChanged = result.filesAdded + result.filesModified + result.filesRemoved;
2143 return { filesChanged, durationMs: result.durationMs };
2144 },
2145 options,
2146 process.platform === 'win32'
2147 ? (filePath) => this.isIndexedFileStateCurrent(filePath)
2148 : undefined
2149 );
2150
2151 // A watching graph detects frameworks again as files change: keep what
2152 // detection reads, so that reads only what changed (#2516).
2153 this.orchestrator.setKeepDetectionContents(true);
2154 const started = this.watcher.start();
2155 if (!started) this.orchestrator.setKeepDetectionContents(false);
2156 return started;
2157 }
2158
2159 /**
2160 * Stop watching for file changes.

Callers 10

activateFunction · 0.80
startIndexWatcherMethod · 0.80
degradeWatcherFunction · 0.80
sync.test.tsFile · 0.80
watcher.test.tsFile · 0.80
startFunction · 0.80

Calls 6

syncMethod · 0.95
engineFunction · 0.90
isActiveMethod · 0.80
startMethod · 0.65

Tested by 2

degradeWatcherFunction · 0.64
startFunction · 0.64