Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const chokidar = require('chokidar')
- export let cacheMap = new Map()
- export default function watchChange(){
- chokidar.watch('src/firmware', {
- persistent: true,
- }).on('all', (event, path) => {
- if (event == "add") {
- cacheMap.set(path.substr(20, 8) + "_" + path.substr(-3), path.substr(13))
- }
- if (event == "unlink") {
- cacheMap.delete(path.substr(20, 8) + "_" + path.substr(-3))
- } else {
- return cacheMap
- }
- })
- return cacheMap
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement