summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-read-stream-patch-open.js
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-08-09 09:01:43 +0200
committerRich Trott <rtrott@gmail.com>2019-10-12 13:13:34 -0700
commit773769df60ac4f2448fa88b2ece035de2512928f (patch)
treec27db6e5829bb3ad8c0c0b398104aedbfc597d3a /test/parallel/test-fs-read-stream-patch-open.js
parent039eb5624950ca5eba46fad8ab78924441d7acfc (diff)
downloadandroid-node-v8-773769df60ac4f2448fa88b2ece035de2512928f.tar.gz
android-node-v8-773769df60ac4f2448fa88b2ece035de2512928f.tar.bz2
android-node-v8-773769df60ac4f2448fa88b2ece035de2512928f.zip
fs: add runtime deprecate for file stream open()
WriteStream.open() and ReadStream.open() are undocumented internal APIs that do not make sense to use in userland. File streams should always be opened through their corresponding factory methods (fs.createWriteStream() and fs.createReadStream()) or by passing a file descriptor in options. PR-URL: https://github.com/nodejs/node/pull/29061 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-fs-read-stream-patch-open.js')
-rw-r--r--test/parallel/test-fs-read-stream-patch-open.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/parallel/test-fs-read-stream-patch-open.js b/test/parallel/test-fs-read-stream-patch-open.js
new file mode 100644
index 0000000000..80f8888de3
--- /dev/null
+++ b/test/parallel/test-fs-read-stream-patch-open.js
@@ -0,0 +1,15 @@
+'use strict';
+const common = require('../common');
+const fs = require('fs');
+
+common.expectWarning(
+ 'DeprecationWarning',
+ 'ReadStream.prototype.open() is deprecated', 'DEP0XXX');
+const s = fs.createReadStream('asd')
+ // We don't care about errors in this test.
+ .on('error', () => {});
+s.open();
+
+// Allow overriding open().
+fs.ReadStream.prototype.open = common.mustCall();
+fs.createReadStream('asd');