mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
74e0ca3f49
PR-URL: https://github.com/nodejs/node/pull/49125 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
21 lines
611 B
JavaScript
21 lines
611 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
const assert = require('assert');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const file = tmpdir.resolve('write_stream_filehandle_test.txt');
|
|
const input = 'hello world';
|
|
|
|
tmpdir.refresh();
|
|
|
|
fs.promises.open(file, 'w+').then((handle) => {
|
|
handle.on('close', common.mustCall());
|
|
const stream = fs.createWriteStream(null, { fd: handle });
|
|
|
|
stream.end(input);
|
|
stream.on('close', common.mustCall(() => {
|
|
const output = fs.readFileSync(file, 'utf-8');
|
|
assert.strictEqual(output, input);
|
|
}));
|
|
}).then(common.mustCall());
|