node/test/parallel/test-module-binding.js
Masashi Hirano 1e23e3ceb3 fs: make process.binding('fs') internal
Refs: https://github.com/nodejs/node/issues/22160

PR-URL: https://github.com/nodejs/node/pull/22478
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2018-11-16 21:56:29 +09:00

18 lines
699 B
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const fixtures = require('../common/fixtures');
const { internalBinding } = require('internal/test/binding');
const { internalModuleReadJSON } = internalBinding('fs');
const { readFileSync } = require('fs');
const { strictEqual } = require('assert');
strictEqual(internalModuleReadJSON('nosuchfile'), undefined);
strictEqual(internalModuleReadJSON(fixtures.path('empty.txt')), undefined);
strictEqual(internalModuleReadJSON(fixtures.path('empty-with-bom.txt')),
undefined);
{
const filename = fixtures.path('require-bin/package.json');
strictEqual(internalModuleReadJSON(filename), readFileSync(filename, 'utf8'));
}