Skip to content
Merged
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: 2 additions & 0 deletions src/cli/commands/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const command: CommandDefinition = {
name: 'watch [dir]',
description: 'Watch project for file changes and incrementally update the graph',
options: [
['-d, --db <path>', 'Path to graph.db'],
['--poll', 'Use stat-based polling (default on Windows to avoid ReFS/Dev Drive crashes)'],
['--native', 'Force native OS file watchers instead of polling'],
['--poll-interval <ms>', 'Polling interval in milliseconds (default: 2000)'],
Expand All @@ -22,6 +23,7 @@ export const command: CommandDefinition = {
engine,
poll,
pollInterval: opts.pollInterval ? Number(opts.pollInterval) : undefined,
dbPath: opts.db ? path.resolve(opts.db) : undefined,
});
},
};
6 changes: 3 additions & 3 deletions src/domain/graph/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ interface WatcherContext {
}

/** Initialize DB, engine, cache, and statements for watch mode. */
function setupWatcher(rootDir: string, opts: { engine?: string }): WatcherContext {
const dbPath = path.join(rootDir, '.codegraph', 'graph.db');
function setupWatcher(rootDir: string, opts: { engine?: string; dbPath?: string }): WatcherContext {
const dbPath = opts.dbPath ?? path.join(rootDir, '.codegraph', 'graph.db');
if (!fs.existsSync(dbPath)) {
throw new DbError('No graph.db found. Run `codegraph build` first.', { file: dbPath });
}
Expand Down Expand Up @@ -297,7 +297,7 @@ function setupShutdownHandler(ctx: WatcherContext, cleanup: () => void): void {

export async function watchProject(
rootDir: string,
opts: { engine?: string; poll?: boolean; pollInterval?: number } = {},
opts: { engine?: string; poll?: boolean; pollInterval?: number; dbPath?: string } = {},
): Promise<void> {
const ctx = setupWatcher(rootDir, opts);

Expand Down
Loading