typed-css-modules icon indicating copy to clipboard operation
typed-css-modules copied to clipboard

Only handle '.css' files in writeFile

Open tolu opened this issue 4 years ago • 0 comments

Description

Chokidar can trigger writeFile for files that glob() does not (see example of issue in screenshot).

In our case, starting watch on pattern packages/**/*.module.css in a monorepo has chokidar trigger for files like:

  • packages/apps/WebApp/node_modules/.bin/lint-staged
  • packages/apps/WebApp/node_modules/.bin/prettier

It seems that the issue is caused by chokidar using glob-parent that handles recursive patterns in a different way than glob.

Solution

Adding an extra precaution that checks .css extension before writing file to skip avoidable error logs. Not perfect but feels ok to require .css-extension in this module.

Error screenshot

image

tolu avatar Dec 20 '21 13:12 tolu