diff --git a/lib/module.js b/lib/module.js index cc8d5097bb83b2..45be3dab86fbd3 100644 --- a/lib/module.js +++ b/lib/module.js @@ -31,7 +31,7 @@ const fs = require('fs'); const internalFS = require('internal/fs'); const path = require('path'); const { - internalModuleReadFile, + internalModuleReadJSON, internalModuleStat } = process.binding('fs'); const preserveSymlinks = !!process.binding('config').preserveSymlinks; @@ -114,7 +114,7 @@ function readPackage(requestPath) { return entry; const jsonPath = path.resolve(requestPath, 'package.json'); - const json = internalModuleReadFile(path.toNamespacedPath(jsonPath)); + const json = internalModuleReadJSON(path.toNamespacedPath(jsonPath)); if (json === undefined) { return false; diff --git a/src/node_file.cc b/src/node_file.cc index 216b60485663b6..6c2c9df86d97c2 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -470,7 +470,7 @@ void FillStatsArray(double* fields, const uv_stat_t* s) { // a string or undefined when the file cannot be opened. Returns an empty // string when the file does not contain the substring '"main"' because that // is the property we care about. -static void InternalModuleReadFile(const FunctionCallbackInfo& args) { +static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); uv_loop_t* loop = env->event_loop(); @@ -1430,7 +1430,7 @@ void InitFs(Local target, env->SetMethod(target, "rmdir", RMDir); env->SetMethod(target, "mkdir", MKDir); env->SetMethod(target, "readdir", ReadDir); - env->SetMethod(target, "internalModuleReadFile", InternalModuleReadFile); + env->SetMethod(target, "internalModuleReadJSON", InternalModuleReadJSON); env->SetMethod(target, "internalModuleStat", InternalModuleStat); env->SetMethod(target, "stat", Stat); env->SetMethod(target, "lstat", LStat); diff --git a/test/parallel/test-module-binding.js b/test/parallel/test-module-binding.js index f5c2a794b110c7..bea0c91f0c5bca 100644 --- a/test/parallel/test-module-binding.js +++ b/test/parallel/test-module-binding.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); const fixtures = require('../common/fixtures'); -const { internalModuleReadFile } = process.binding('fs'); +const { internalModuleReadJSON } = process.binding('fs'); const { readFileSync } = require('fs'); const { strictEqual } = require('assert'); -strictEqual(internalModuleReadFile('nosuchfile'), undefined); -strictEqual(internalModuleReadFile(fixtures.path('empty.txt')), ''); -strictEqual(internalModuleReadFile(fixtures.path('empty-with-bom.txt')), ''); +strictEqual(internalModuleReadJSON('nosuchfile'), undefined); +strictEqual(internalModuleReadJSON(fixtures.path('empty.txt')), ''); +strictEqual(internalModuleReadJSON(fixtures.path('empty-with-bom.txt')), ''); { const filename = fixtures.path('require-bin/package.json'); - strictEqual(internalModuleReadFile(filename), readFileSync(filename, 'utf8')); + strictEqual(internalModuleReadJSON(filename), readFileSync(filename, 'utf8')); }