mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 16:34:41 +00:00

Adds type validation to options fd & opts in `fs.createWriteStream` and `fs.createReadStream`. Fixes: https://github.com/nodejs/node/issues/35178 PR-URL: https://github.com/nodejs/node/pull/35187 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
50 lines
742 B
JavaScript
50 lines
742 B
JavaScript
'use strict';
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
|
|
{
|
|
const fd = 'k';
|
|
|
|
assert.throws(
|
|
() => {
|
|
fs.createReadStream(null, { fd });
|
|
},
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
});
|
|
|
|
assert.throws(
|
|
() => {
|
|
fs.createWriteStream(null, { fd });
|
|
},
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
});
|
|
}
|
|
|
|
{
|
|
const path = 46;
|
|
|
|
assert.throws(
|
|
() => {
|
|
fs.createReadStream(path);
|
|
},
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
});
|
|
|
|
assert.throws(
|
|
() => {
|
|
fs.createWriteStream(path);
|
|
},
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
});
|
|
}
|