Skip to content

Instantly share code, notes, and snippets.

@trevorfoskett
Created March 31, 2020 20:28
Show Gist options
  • Save trevorfoskett/0ae15b5851fcf6cb9e061d199b171346 to your computer and use it in GitHub Desktop.
Save trevorfoskett/0ae15b5851fcf6cb9e061d199b171346 to your computer and use it in GitHub Desktop.
Creating a folder watcher with Chokidar
// 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