Skip to content

watchFile to support directory as well #2997

Open
@sudoaugustin

Description

@sudoaugustin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions