mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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>
35 lines
852 B
JavaScript
35 lines
852 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
// Run in a child process because 'out' is opened twice, blocking the tmpdir
|
|
// and preventing cleanup.
|
|
if (process.argv[2] !== 'child') {
|
|
// Parent
|
|
const assert = require('assert');
|
|
const { fork } = require('child_process');
|
|
tmpdir.refresh();
|
|
|
|
// Run test
|
|
const child = fork(__filename, ['child'], { stdio: 'inherit' });
|
|
child.on('exit', common.mustCall(function(code) {
|
|
assert.strictEqual(code, 0);
|
|
}));
|
|
|
|
return;
|
|
}
|
|
|
|
// Child
|
|
|
|
common.expectWarning(
|
|
'DeprecationWarning',
|
|
'WriteStream.prototype.open() is deprecated', 'DEP0XXX');
|
|
const s = fs.createWriteStream(`${tmpdir.path}/out`);
|
|
s.open();
|
|
|
|
// Allow overriding open().
|
|
fs.WriteStream.prototype.open = common.mustCall();
|
|
fs.createWriteStream('asd');
|