Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Global variable alert! #2

Closed
jakobmattsson opened this issue Apr 10, 2011 · 1 comment
Closed

Global variable alert! #2

jakobmattsson opened this issue Apr 10, 2011 · 1 comment
Assignees

Comments

@jakobmattsson
Copy link

Hi,

Nice functions, saved me the trouble of writing them myself. On the other hand, I found some issues and would like to make you aware of them. The following lines are not doing what you think (or you might just have done some naughty copy-pasting):

var contents = fs.readFileSync(sourceDir + "/" + files[i], encoding="utf8");
fs.writeFileSync(newDirLocation + "/" + files[i], contents, encoding="utf8");

The last parameter in both lines are an expression that creates a global variable called "encoding", sets it to "utf8" and then passes the value of "encoding" to the function. Remove "encoding=" and just use "utf8" as a parameter instead.

By the way, setting the encoding to utf8 doesn't really work well with binary files, like images. I would just skip the encoding parameter altogether.

Cheers!

@ghost ghost assigned ryanmcgrath Apr 10, 2011
ryanmcgrath pushed a commit that referenced this issue Apr 10, 2011
@ryanmcgrath
Copy link
Owner

Hey,

Thanks for pointing this out! I had been meaning to circle around and fix it for months; this was abstracted out of a personal project many moons ago, and as such definitely had one or two warts since I kind of just threw it out there for people to use.

Resolved in 445a283. Thanks!

  • Ryan

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants