From fea1e05ba5588eeedc670c5bcfff9a362874deed Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 16 Nov 2017 13:12:04 -0800 Subject: [PATCH] module: rename internalModuleReadFile to internalModuleReadJSON PR-URL: https://github.com/nodejs/node/pull/17084 Fixes: https://github.com/nodejs/node/issues/17076 Reviewed-By: Rich Trott Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- lib/module.js | 4 ++-- src/node_file.cc | 4 ++-- test/parallel/test-module-binding.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/module.js b/lib/module.js index b22ba4fe66337a..79c93a5aef4850 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; @@ -122,7 +122,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 2b3b007976de14..c178ec9ac1f1fd 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -518,7 +518,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(); @@ -1478,7 +1478,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')); }