Skip to content

Commit

Permalink
Update usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
timursevimli committed Nov 9, 2023
1 parent 76ced1d commit 26fc864
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,41 @@
```js
const metawatch = require('metawatch');

const watcher = new metawatch.DirectoryWatcher({ timeout: 200 });
const options = {
timeout: 200,
excludes: {
dirs: ['.git', 'node_modules'],
files: ['package.json'],
exts: ['jsx', 'ts'],
},
};

const watcher = new metawatch.DirectoryWatcher();
watcher.watch('/home/marcus/Downloads');
watcher.watch('/home/marcus/Documents');

watcher.on('change', (fileName) => {
console.log({ changed: fileName });
});

watcher.on('delete', (fileName) => {
watcher.on('unlink', (fileName) => {
console.log({ deleted: fileName });
});

watcher.on('unlinkDir', (dirName) => {
console.log({ deleted: dirName });
});

watcher.on('before', (changes) => {
console.log({ changes });
console.log({ before: changes });
});

watcher.on('after', (changes) => {
console.log({ changes });
console.log({ after: changes });
});

watcher.on('*', (change) => {
console.log({ change });
});
```

Expand Down

0 comments on commit 26fc864

Please sign in to comment.