Closed Xeio closed 8 years ago
I've just tested this change against a project with this issue when using grunt-contrib-jasmine to run tests. On my Windows 7 machine it looks like it has fixed the problem.
I think a best approach would be using rimraf
to remove the temp file.
Would you mind updating this PR to use rimraf
instead, of course if you have the time to.
Updated PR.
Merged. Thanks :)
Closed the previous request, this is an alternative changeset.
This should behave a little more deterministically as the file gets deleted after the process using it is terminated. Additional upside to this is that PhantomJS won't be able to write to the temp file after we delete it.
I was unable to get graceful-fs to work without a similar retry mechanism, though I did see EPERM errors instead of EBUSY. Maybe there's some additional configuration needed that I missed but I couldn't find it.
Possibly the retry timeout should be configurable, but the OS usually unlocks the file almost immediately once the process is terminated. It was working for me even with a setTimout of zero, so the 100 is mostly arbitrary.