fastify-cli
fastify-cli copied to clipboard
Only watch specified directory (--watch CLI param)
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Allow a directory (or list of directories) to be passed into the --watch param
Motivation
In my project, I have a small API subfolder. When I turn on --watch, it is monitoring my entire project root for changes, which leads to resets constantly.
Example
Right now the only solution is to do something like this:
fastify start --watch --ignore-watch '.git node_modules out .next content public scripts utils styles pages config compontents' --log-level info --pretty-logs --port ${API_PORT:-4321} api/server.js
I would rather do this:
fastify start --watch api --log-level info --pretty-logs --port ${API_PORT:-4321} api/server.js
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
Good idea @ActivistChecklist,
Maybe look at the ignore-watch related code to take inspiration and do it the other way.
I've gone crazy with Watch and the problem is the code below that is crazy (and obviously undocumented)
I needed to watch only in "dist". But nothing work. And now I know why. Because fastify add dist by default. But if I ignore ".ts$", voilà 👎
Ok if I don't set anything but I think that if I set ignore-watch I know what folders I want to exclude.
From: https://github.com/fastify/fastify-cli/blob/590f350d1a586f68e78ecc72a8cc1b17ce1507a0/args.js#L7C1-L7C93
const DEFAULT_IGNORE = 'node_modules build dist .git bower_components logs .swp .nyc_output'
.....
let ignoreWatch = `${DEFAULT_IGNORE} ${ignoreWatchArg}`.trim()
if (ignoreWatchArg.includes('.ts$')) {
ignoreWatch = ignoreWatch.replace('dist', '')
}
Is this task still active? I noticed a PR has been opened but not reviewed yet. https://github.com/fastify/fastify-cli/pull/794 If it's still ongoing, I'd be happy to take it on. @mcollina @jean-michelet
Yes, I think so! I'm sorry I missed the original PR!