yeoman/generator — pull request #292 by jdespatis (2013-06-14 07:46:56+00:00)
Title: Fixes #237, binary files were always in conflict, even for same files

More information in the code.

The key to solve this problem is to compare 2 `Buffer` objects (standard `===` comparison doesn't work as we have 2 different objects with same content, not the same reference).

Several technics exist to compare 2 objects.
As the binary is a file, I've used `Buffer` API in order to encode each one in hexa, and then compare the hexa resulting strings

(I've not done any benchmark, but I guess hex is one of the fastest, compare to base64 for example, giving a string that can be compared with another one)

All encoding supported by the class `Buffer` are indicated here fyi:
http://nodejs.org/api/buffer.html#buffer_buffer

In `actions.js`, I've changed `utf-8` to `utf8`, in order to have the same encoding as the one already indicated into `conflicter.js`.
Further more, I only see `utf8` (and not `utf-8`) in Node.js API:
http://nodejs.org/api/fs.html#fs_fs_writefile_filename_data_options_callback

(Indeed `utf-8` and `utf8` give same effect, but `utf8`is better to get closer to Node.js API, I would say)

Feel free to comment on the logic used to compare the 2 Buffer objects.

The fact is this technic work nicely, but maybe a far better solution exists.
I'll update the PR according to your feedbacks