-
Notifications
You must be signed in to change notification settings - Fork 54
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
Watch target files with Chokidar #30
base: master
Are you sure you want to change the base?
Watch target files with Chokidar #30
Conversation
Author: Blake Mealey <[email protected]>
@@ -251,16 +348,16 @@ describe('Options', () => { | |||
expect(console.log).toHaveBeenCalledTimes(5) | |||
expect(console.log).toHaveBeenCalledWith(green('copied:')) | |||
expect(console.log).toHaveBeenCalledWith( | |||
green(` ${bold('src/assets/asset-1.js')} → ${bold('dist/asset-1.js')}`) | |||
green(` ${bold('src/assets/asset-1.js')} → ${bold(join('dist', 'asset-1.js'))}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was broken on Windows because it was getting 'dist\asset-1.js' instead of 'dist/asset-1.js'
join
fixes this by using the separator from the OS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, so it outputs backslashes on windows 🤔
I'll try to resolve this in src
code so paths won't be different in mac/windows since this doesn't match with target.src
ones.
Codecov Report
@@ Coverage Diff @@
## master #30 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 36 49 +13
Branches 12 14 +2
=====================================
+ Hits 36 49 +13
Continue to review full report at Codecov.
|
Time to check this one, thank you for helping :) |
await copyFiles(copyTargets, verbose, copyOptions) | ||
} | ||
|
||
return chokidar.watch(src, { ignoreInitial: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, we can't pass src
to chokidar. Chokidar v3 uses anymatch, which uses picomatch inside:
chokidar -> anymatch -> picomatch
This package uses globby inside for glob support. Globby uses fast-glob inside, which uses micromatch:
globby -> fast-glob -> micromatch -> picomatch
So, chokidar v3 misses micromatch package which adds support for some glob features on top of picomatch. Globs will have different features for copy and watch. Chokidar used micromatch in v2, but switched in v3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's unfortunate... I'll think about it a bit and do some research into options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened an issue in chokidar paulmillr/chokidar#956, maybe only braces extension is missing and we can live with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be compatible. I'll add few tests this week and hopefully release a new version after merging this.
I've checked and tested this a bit. Everything is fine, except glob support. Chokidar uses I'm not sure how to solve this, need to find a way chokidar use |
This can be accomplished with rollup's |
@bennypowers unfortunately that didn't fit all requirements, see: #27 (comment) @vladshcherbin any update on merging this? |
Bump 😃 |
Fixes: #5
New PR for watching targeted files, this time using Chokidar as we discussed.
We discussed using
process.on('exit', ...)
to close watchers, but I found this wasn't feasible because that requires sync operations and closing Chokidar is async. I made an issue on Chokidar and they said there's no need to close them manually (see paulmillr/chokidar#945).