-
Notifications
You must be signed in to change notification settings - Fork 2
Add custom watched and ignored files #8
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
base: main
Are you sure you want to change the base?
Conversation
@@ -28,7 +28,7 @@ module Chokidar = { | |||
type watchOptions = {ignored?: array<string>, ignoreInitial?: bool} | |||
|
|||
@send | |||
external watch: (t, string, ~options: watchOptions=?) => Watcher.t = "watch" | |||
external watch: (t, array<string>, ~options: watchOptions=?) => Watcher.t = "watch" |
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.
Now that we might have multiple globs, swapped out the overload we're hitting.
module MicroMatch = { | ||
type mm = { | ||
makeRe: string => RegExp.t | ||
} | ||
@module("micromatch") | ||
external mm: mm = "default" | ||
} | ||
|
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.
fast-glob
already depends on micromatch
, so we can use this to test glob matches for free.
@@ -166,6 +174,24 @@ type handleOtherCommandConfig<'config> = { | |||
|
|||
type setupConfig = {args: CliArgs.t} |
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.
Initially, I had tinkered with adding a parameter here, which would have avoided the breaking change to setup
's return type.
type setupConfig = {
args: CliArgs.t,
addWatcher: watcher => unit
}
However, I realized that with this API, an embed developer could then start doing funny things with addWatcher
(e.g. add new watchers after we've already started watching), which would be a whole new can of worms to worry about. By using the return type, we force all watchers to be known once setup
is done.
@unboxed | ||
type setupResult<'config> = | ||
| SetupResult({ | ||
config: 'config, | ||
additionalFileWatchers?: array<watcher>, | ||
additionalIgnorePatterns?: array<string> | ||
}) |
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.
Initially used a plain-ol' record here, but that caused some inference issues due to the config
parameter, so I swapped it out for the unboxed single-case variant to sidestep that issue.
generate: generateConfig<'config> => promise<result<generated, string>>, | ||
cliHelpText: string, | ||
handleOtherCommand?: handleOtherCommandConfig<'config> => promise<unit>, | ||
onWatch?: onWatchConfig<'config> => promise<unit>, | ||
} | ||
|
||
let defaultSetup = async _ => () | ||
let defaultSetup = async (_): setupResult<_> => SetupResult({config: ()}) |
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.
As promised, the return type is a breaking change.
Console.log(`Watching the following patterns for file changes...`) | ||
Array.forEach(watchedFiles, f => Console.log(`- ${f}`)) |
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.
Tweaked the display here so we can show all the globs we're keeping an eye on.
Great! I'm a bit low on time at the moment but will hopefully get around to this soon. |
No worries! |
As promised, I took a shot at allowing the user to add watched files. This'll allow embed authors to keep an eye on configuration files, and regenerate should they change.