1 | <div align="center">
|
2 | <img src="https://github.com/marshallcb/watches/raw/main/meta/watches.png" alt="watches" width="75" />
|
3 | </div>
|
4 |
|
5 | <h1 align="center">watches</h1>
|
6 | <h3 align="center">Watch ES6 modules and their dependencies for changes</h3>
|
7 |
|
8 | <div align="center">
|
9 | <a href="https://npmjs.org/package/watches">
|
10 | <img src="https://badgen.now.sh/npm/v/watches" alt="version" />
|
11 | </a>
|
12 | <a href="https://packagephobia.com/result?p=watches">
|
13 | <img src="https://badgen.net/packagephobia/install/watches" alt="install size" />
|
14 | </a>
|
15 | </div>
|
16 |
|
17 | # API
|
18 |
|
19 | ### `watch(source, options)`
|
20 |
|
21 | ```js
|
22 | watch(['src','static'], {
|
23 | cache: require.cache, // to automatically clear require.cache on changes
|
24 | ignore: /(^|[\/\\])[\._]./, //ignore files/folders with . or _ prefix
|
25 | only: /\.js$/ // only files with a .js extension
|
26 | }).on('ready', (all) => {
|
27 | console.log("READY")
|
28 | console.log(all)
|
29 | }).on('change', (changed, all) => {
|
30 | console.log("CHANGE")
|
31 | console.log(changed)
|
32 | console.log(changed.length + ' targets affected')
|
33 | }).on('remove', (removed) => {
|
34 | console.log("REMOVE")
|
35 | console.log(removed)
|
36 | }).on('error', (e) => {
|
37 | console.log("ERROR")
|
38 | console.log(e)
|
39 | })
|
40 | ```
|
41 |
|
42 | ### `scan(source, options)`
|
43 |
|
44 | ```js
|
45 | let files = scan(['src','static'], {
|
46 | ignore: /(^|[\/\\])[\._]./, //ignore files/folders with . or _ prefix
|
47 | only: /\.js$/ // only files with a .js extension
|
48 | })
|
49 | console.log(files) // all matching files
|
50 | ```
|
51 |
|
52 | ## License
|
53 |
|
54 | MIT © [Marshall Brandt](https://m4r.sh) |
\ | No newline at end of file |