Atom saves my JS files twice; Triggers double events in CodeKit


#1

I have CodeKit set to watch for when I save JavaScript files. When it sees a file saved (which it does reliably), it runs JSLint on it and creates a single minified JS file containing the new changes and my other JS files.

When I save with Atom, I see the above triggered twice in a row. I haven’t seen this behavior with other editors like Vim, Dreamweaver, or SublimeText.

Has anyone else seen this? Is it intentional? Can it be disabled?

UPDATE: Now it’s saving 3 times when I hit CTRL-S


#2

So, am I the only one who is seeing this issue? Does anyone have tools that might allow them to see how many times a file gets saved each time you initiate one, but are not seeing this issue?


#3

I can’t find the discussion I saw at one point, but Ruby’s Guard is a system that monitors the filesystem and executes tasks based on “save” events happening on which paths within a project. It has had a whole slew of problems of this sort with various editors and across operating systems.

The file system events that occur to save a file are complicated and vary from editor to editor, because it, from what I saw, isn’t as simple as “open file, write contents, close file” … at least from a file system point of view. Some editors back up the file to a temp directory or temp file first, some seemingly write the contents twice, some seem to open the file, read the contents, close the file and then open it again to save the contents … all for one save.

I don’t use CodeKit, so I haven’t seen this issue … but I don’t see it with Guard.


#4

Thanks Lee,

If others aren’t seeing it, there might be something else about my setup that’s causing the multiple saves.

I appreciate your response.


#5

I see this behavior on windows (saves twice, not three times). This happens for all files, js, html, perl, and others. I’m running rsync on file changes so it’s kind of annoying.

It does not seem to save twice on a new file - I get one create event and one update event.


#6

Ah ha! I found it …

Check out the issue for all the nitty gritty details of how files are saved by various Linux editors. The point being that performing more than one operation on save is not only common, it’s nigh universal. Personally, I don’t think it is the editor’s job to jump through hoops to save the file just the way a bunch of other systems want it to. I feel it is up to the systems doing the file system monitoring to properly coalesce events so as not to do more work than they have to.