Skip to content

Commit b1f1cca

Browse files
committed
fix(cli): correct watch ignore logic
1 parent 690dec0 commit b1f1cca

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

packages/cli/src/app.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ await yargs(hideBin(process.argv))
116116
const closeHandlers: (() => Promise<void>)[] = [];
117117
const resolvedDir = path.resolve(args.dir);
118118

119-
await bundleSource(resolvedDir, logger);
120-
121119
const handleClose = async (): Promise<void> => {
122120
await Promise.all(
123121
closeHandlers.map(async (close) => withTimeout(close(), 400)),

packages/cli/src/commands/watch.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { makePromiseKit } from '@endo/promise-kit';
22
import { Logger } from '@ocap/utils';
33
import { watch } from 'chokidar';
4-
import type { FSWatcher, MatchFunction } from 'chokidar';
4+
import type { FSWatcher } from 'chokidar';
55
import { unlink } from 'fs/promises';
66
import { resolve } from 'path';
77

@@ -56,9 +56,6 @@ export const makeWatchEvents = (
5656
error: (error: Error) => throwError(error),
5757
});
5858

59-
export const filterOnlyJsFiles: MatchFunction = (file, stats) =>
60-
(stats?.isFile() ?? false) && file.endsWith('.js');
61-
6259
/**
6360
* Start a watcher that bundles `.js` files in the target dir.
6461
*
@@ -77,14 +74,14 @@ export function watchDir(dir: string, logger: Logger): WatchDirReturn {
7774
const { reject: throwError, promise: errorPromise } = makePromiseKit<never>();
7875

7976
let watcher = watch(resolvedDir, {
80-
ignoreInitial: true,
81-
ignored: [
82-
'**/node_modules/**',
83-
'**/*.test.js',
84-
'**/*.test.ts',
85-
'**/*.bundle',
86-
filterOnlyJsFiles,
87-
],
77+
ignoreInitial: false,
78+
ignored: (file, stats) =>
79+
// Ignore node_modules
80+
file.includes('node_modules') ||
81+
// Watch directories (and the files they contain)
82+
((stats?.isFile() ?? false) &&
83+
// But only trigger on JS files
84+
!file.endsWith('.js')),
8885
});
8986

9087
const events = makeWatchEvents(watcher, readyResolve, throwError, logger);

0 commit comments

Comments
 (0)