cowboy/grunt — pull request #30 by mklabs (2012-02-04 10:23:00+00:00)
Title: File copy: handle non utf8 files

Hi there,

Here's a little patch to handle the copy of files which are non necessarily utf8 files. I came accross the issue while copying images through `file.copy`.

Here's the commit msg:

> slight changes to file read/write/copy to handle non utf8 files

> Introduced an encoding option on file.read when set to a truthy value will
return the raw buffer instead. If none or falsy value is specified, encoding defaults
to utf8.

> Should ensure that defaults file.read behaviour stay the same while
allowing file.copy to work with buffers and properly handle non
utf8 files such as images and binaries.

I've also added a new test suite and tried to cover most of different use cases for each notable changes.

Let me know if there's anything that needs to be changed, or if I should add more tests to handle cases I might have missed :)

*Side note*: I didn't want to include this in this pull request, but I got a little issue with filepaths provided to nodeunit. The issue happened right after I uninstalled my globally installed grunt to link the grunt version from master. I added (1d3d5f668096d850ceecfd169b83cad139a9def8) this little change, which should handle both absolute / relative to cwd paths in the same way.