Last active
November 9, 2018 15:57
-
-
Save maciejcieslar/1c1f79d5778af4c2ee17927de769cea3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isInDirectory = (directories: string[]) => (filePath: string) => | |
directories.some(filePath.startsWith.bind(filePath)) | |
const isExpectedExtension = (extensions: string[]) => (extension: string) => | |
extensions.some(is(extension)) | |
// ... | |
const shouldPathBeIgnored = isInDirectory(ignoredDirectories) | |
const shouldPathBeWatched = isInDirectory(watchedDirectories) | |
const shouldExtensionBeWatched = isExpectedExtension(extensions) | |
// ... | |
fromEvent(chokidar.watch(process.cwd()), 'all').pipe( | |
// ... | |
filter( | |
({ filePath, extension }) => | |
(shouldWatchEveryDirectory || shouldPathBeWatched(filePath)) && | |
(shouldWatchEveryExtension || shouldExtensionBeWatched(extension)) && | |
not(shouldPathBeIgnored(filePath)), | |
), | |
// ... | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment