Given the following piece of code from my gulpfile.js, everytime I save or change a file, the task runs twice instead of one single time, why is that? I just want it to run
The problem is occurring because your editor, in this case Coda 2, is modifying the file twice on save. The same problem occurs in vim because of how vim creates buffer backups on save.
The solution to the problem in vim is to add
set nowritebackup
to your ~/.vimrc
file. This changes the default save protocol to only make one edit to the original file.
In other words, the default save protocol is as follows:
And adding set nowritebackup
simply replaces the original file on save. This protocol exists to reduce risk of data loss in the event of an I/O error on save.