Carrooi / Node-FsMock

[ABANDONED] Mock for fs module
MIT License
7 stars 2 forks source link

createReadStream/createWriteStream should emit "error" events instead of throwing exceptions #2

Closed ericlathrop closed 10 years ago

ericlathrop commented 10 years ago

Thanks so much for this wonderful module! It has saved me much time, since I don't have to write something similar.

I bumped into a case where the mock has different behaviour from the real fs package. Normally fs.createReadStream/fs.createWriteStream should never throw errors, but instead emit an error event.

I looked through the code, and saw that it's using openSync which is throwing exceptions: https://github.com/sakren/node-fs-mock/blob/master/lib/fs.js#L1179 https://github.com/sakren/node-fs-mock/blob/master/lib/fs.js#L1215

These exceptions should be caught and transformed into error events.

ericlathrop commented 10 years ago

I haven't done much CoffeeScript, but if I figure out how to fix this, would you accept a pull request?

davidkudera commented 10 years ago

Oh, I thank you sir :)

I accept pull requests but if you want, you can send me here (to comments) updated javascript and I can rewrite it to coffee script. Comment because if you will make pull request with just js, it will be rewritten by coffee script compiler. Than I will mention you in comment in code and in changelog.

ericlathrop commented 10 years ago

I made some progress on this last night. I got the createReadStream() now emitting the error event instead of throwing an exception. Now I'm working on createWriteStream().

davidkudera commented 10 years ago

Brilliant. And can I please ask you to create pull request from develop branch?

ericlathrop commented 10 years ago

Sure! I just got createWriteStream's error event working. Expect a pull request soon.