balderdashy / balderdashy/sails
how to use chokidar for clearing file cache ?
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**Sails version**: 0.12.14
**Node version**: 8.9.4
**NPM version**: 6.0.1
**DB adapter name**: N/A
**DB adapter version**: N/A
**Operating system**: windows 10
this is my code for clearing file cache, it works on express but in sails it doesn't work:
config/bootstrap.js:
```
const pathName = path.join(__dirname, '../api');
const watcher = chokidar.watch(pathName);
watcher.on('ready', () => {
console.log('ready to watch')
watcher.on('all', () => {
Object.keys(require.cache).forEach((id) => {
console.log(`Clearing ${id} module cache from server`)
if (/[\/\\]app[\/\\]/.test(id)) delete require.cache[id];
});
});
});
```
Contributor guide
Research direction
Read config/bootstrap.js and the Sails bootstrap behavior around the chokidar watcher and require.cache; first reproduce the reported difference on Sails 0.12.14 with Node 8.9.4 on Windows 10. Done means the Sails-specific cause is identified and the expected cache-clearing behavior is verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100