Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ignoreDirectoryPattern #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Leonid-Yeromin
Copy link

Fix problem with watching directory ignored in ignoreDirectoryPattern
jasmine tests added:
npm test

@@ -51,6 +51,7 @@ function walk (dir, options, callback) {
if (!enoent) {
if (options.ignoreDotFiles && path.basename(f)[0] === '.') return done && callback(null, callback.files);
if (options.filter && !options.filter(f, stat)) return done && callback(null, callback.files);
if (options.ignoreDirectoryPattern && options.ignoreDirectoryPattern.test(f)) return done && callback(null, callback.files);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think stat.isDirectory() is necessary, otherwise not only the directories but also the files match to ignoreDirectoryPattern is also ignored.

Copy link

@kena0ki kena0ki Apr 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I also tried to fix this issue. Here is my patch.

@kena0ki
Copy link

kena0ki commented Apr 5, 2020

This would fix #95 and #115.

As this repository hasn't been maintained for a long time, here is the note for someone wants to use the fixed version of this issue.
We can use the forked version of this repository by writing package.json in the following way:

  "dependency":
    "watch":  "Leonid-Yeromin/watch" (or "kena0ki/watch")

@KyleSmith0905
Copy link

@kena0ki I've installed your version and ran both of the following scripts:

watch --ignoreDirectoryPattern=/.*/ '<script>'
watch --ignoreDirectoryPattern=/dist/ '<script>'

Neither could get my dist folder ignored (despite using a catchall regex)?

Do you have an example on how to use this or am I doing it wrong?

@kena0ki
Copy link

kena0ki commented Sep 17, 2023

Maybe it's not 'dependency' but 'dependencies'.
Sorry for my typo.

  "dependencies":  {
    "watch":  "Leonid-Yeromin/watch" (or "kena0ki/watch")
  }

@KyleSmith0905
Copy link

I understood what you meant, it's fine, I no longer need a solution.

I went with chokidar... I created a script called "watch" whose sole purpose is to run this file:

const build = () => {
	exec('npm run build')
}

chokidar.watch('.', {
	ignored: [
		'dist',
		'node_modules',
		'build.js',
		'package.json',
		'pnpm-lock.yaml',
		'tsconfig.json',
	],
	ignoreInitial: true,
	persistent: true,
}).on('all', () => {
	build();
});

I would've love to have it in my scripts, but I'm not too hurt about it, I'm starting to like having a few scripts handy.

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.

3 participants