When you include a file using the require function in Node, the file will get cached so they don’t have to be loaded a second time when you want to use this specific file again. Most of the time this functionality is pretty handy and there are not many reason to change this functionality. One of the reasons I found was the use of Gulp-Jasmine. When creating a test-script to use with the plugin, you use require to include the file to run the tests on. And here comes the problem. If you change your scripts content and save it, the watch function of Gulp comes in. Within the watch you can call you’re script and voilla, there you go. At least I thought I was going.
Within the plugin there is only one file which gets deleted from the require-cache, the test itself. Pretty obvious to do, because you can now modify your test script file and run it again. The problem is that the actual files to test aren’t deleted from the require-cache. This is what I wanted to change (I found some threads mon stack overflow also on this point, so I’m not the only one I think) and modified the plugin a bit. The only part I’ve added is the code below:
Well what does this little chunk of code do? That’s pretty easy. He’re a little desription of what’s happening:
note: I’ve added a pullrequest for this issue on https://github.com/sindresorhus/gulp-jasmine/pull/21
UPDATE: The pullrequest has been added to the code