Skip to content

fs: Accept a function as an options container.

This is alternate to https://github.com/nodejs/io.js/pull/1982

This should fix a breaking change in commit 353e26e3, that was included in a minor version of io.js and broke at least two modules (that were misusing fs.createWriteStream method, but still).

Those two modules were passing a function to fs.createWriteStream, and that was never supported (it was always ignored). In 2.3.0 a more strict options validation was introduced, it started throwing an Error, and at least those two modules were broken.

This patch uses a simple way to get around that, treating a function as a valid options container.

Apart from functions, 353e26e3 changed the behaviour on falsy variables (null and 0 started causing an Error), and that is not addressed in this PR. I could fix that, replacing the options === undefined with a !options check (that would involve changing the expectations of several tests). What do you think?

@yosuke-furukawa, @chrisdickinson

Fixes: https://github.com/nodejs/io.js/issues/1981

Merge request reports

Loading