Created
March 31, 2020 20:28
-
-
Save trevorfoskett/0ae15b5851fcf6cb9e061d199b171346 to your computer and use it in GitHub Desktop.
Creating a folder watcher with Chokidar
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
// Watch the source folder for changes | |
async function watchFiles(auth) { | |
if (store.get('save_location') !== '') { | |
const watcher = chokidar.watch(store.get('save_location'), { | |
persistent: true, | |
ignoreInitial: true // ignores files that already exist in this folder | |
}); | |
watcher.on('add', async path => { | |
// code to execute when a new file is added | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment