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

watchFile to support directory as well #2997

Open
sudoaugustin opened this issue Dec 26, 2023 · 0 comments
Open

watchFile to support directory as well #2997

sudoaugustin opened this issue Dec 26, 2023 · 0 comments

Comments

@sudoaugustin
Copy link

sudoaugustin commented Dec 26, 2023

Is this a feature request or a bug?

Feature request

What is the current behavior?

When I pass a directory into the watchFile, it emits UsageError.

What is the expected or desired behavior?

Instead of emitting error, it would be better if it add the value into watchedDirs.

Suggested solution.

It'll be beneficial if we change the file watching logic in watcher.js:47-59 into this.

  if (watchFile) {
    for (const filePath of watchFile) {
      if (fs.existsSync(filePath) && !fs.lstatSync(filePath).isFile()) {
        watchedDirs.push(filePath);
      } else {
        watchedFiles.push(filePath);
      }

    }
  } else {
    watchedDirs.push(sourceDir);
  }

Thanks for creating this lib.

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

No branches or pull requests

1 participant