web-ext icon indicating copy to clipboard operation
web-ext copied to clipboard

watchFile to support directory as well

Open sudoaugustin opened this issue 1 year ago • 0 comments

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.

sudoaugustin avatar Dec 26 '23 16:12 sudoaugustin