mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Enable node:vfs by default. --no-experimental-vfs disables node:vfs exposure and --vfs-load. Assisted-by: pi Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/66318 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
22 lines
622 B
JavaScript
22 lines
622 B
JavaScript
// Flags: --disable-warning=ExperimentalWarning
|
|
'use strict';
|
|
|
|
// readFileSync with invalid encoding must throw.
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const vfs = require('node:vfs');
|
|
|
|
const myVfs = vfs.create();
|
|
myVfs.writeFileSync('/file.txt', 'x');
|
|
|
|
assert.throws(
|
|
() => myVfs.readFileSync('/file.txt', { encoding: 'bogus' }),
|
|
/encoding/i,
|
|
);
|
|
|
|
// Valid encodings should work
|
|
assert.strictEqual(myVfs.readFileSync('/file.txt', 'utf8'), 'x');
|
|
assert.strictEqual(myVfs.readFileSync('/file.txt', { encoding: 'utf8' }), 'x');
|
|
assert.deepStrictEqual(myVfs.readFileSync('/file.txt'), Buffer.from('x'));
|