Skip to content

Commit fea1e05

Browse files
jdaltonTrott
authored andcommitted
module: rename internalModuleReadFile to internalModuleReadJSON
PR-URL: #17084 Fixes: #17076 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ecbae56 commit fea1e05

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/module.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const fs = require('fs');
3131
const internalFS = require('internal/fs');
3232
const path = require('path');
3333
const {
34-
internalModuleReadFile,
34+
internalModuleReadJSON,
3535
internalModuleStat
3636
} = process.binding('fs');
3737
const preserveSymlinks = !!process.binding('config').preserveSymlinks;
@@ -122,7 +122,7 @@ function readPackage(requestPath) {
122122
return entry;
123123

124124
const jsonPath = path.resolve(requestPath, 'package.json');
125-
const json = internalModuleReadFile(path.toNamespacedPath(jsonPath));
125+
const json = internalModuleReadJSON(path.toNamespacedPath(jsonPath));
126126

127127
if (json === undefined) {
128128
return false;

src/node_file.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ void FillStatsArray(double* fields, const uv_stat_t* s) {
518518
// a string or undefined when the file cannot be opened. Returns an empty
519519
// string when the file does not contain the substring '"main"' because that
520520
// is the property we care about.
521-
static void InternalModuleReadFile(const FunctionCallbackInfo<Value>& args) {
521+
static void InternalModuleReadJSON(const FunctionCallbackInfo<Value>& args) {
522522
Environment* env = Environment::GetCurrent(args);
523523
uv_loop_t* loop = env->event_loop();
524524

@@ -1478,7 +1478,7 @@ void InitFs(Local<Object> target,
14781478
env->SetMethod(target, "rmdir", RMDir);
14791479
env->SetMethod(target, "mkdir", MKDir);
14801480
env->SetMethod(target, "readdir", ReadDir);
1481-
env->SetMethod(target, "internalModuleReadFile", InternalModuleReadFile);
1481+
env->SetMethod(target, "internalModuleReadJSON", InternalModuleReadJSON);
14821482
env->SetMethod(target, "internalModuleStat", InternalModuleStat);
14831483
env->SetMethod(target, "stat", Stat);
14841484
env->SetMethod(target, "lstat", LStat);

test/parallel/test-module-binding.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
22
require('../common');
33
const fixtures = require('../common/fixtures');
4-
const { internalModuleReadFile } = process.binding('fs');
4+
const { internalModuleReadJSON } = process.binding('fs');
55
const { readFileSync } = require('fs');
66
const { strictEqual } = require('assert');
77

8-
strictEqual(internalModuleReadFile('nosuchfile'), undefined);
9-
strictEqual(internalModuleReadFile(fixtures.path('empty.txt')), '');
10-
strictEqual(internalModuleReadFile(fixtures.path('empty-with-bom.txt')), '');
8+
strictEqual(internalModuleReadJSON('nosuchfile'), undefined);
9+
strictEqual(internalModuleReadJSON(fixtures.path('empty.txt')), '');
10+
strictEqual(internalModuleReadJSON(fixtures.path('empty-with-bom.txt')), '');
1111
{
1212
const filename = fixtures.path('require-bin/package.json');
13-
strictEqual(internalModuleReadFile(filename), readFileSync(filename, 'utf8'));
13+
strictEqual(internalModuleReadJSON(filename), readFileSync(filename, 'utf8'));
1414
}

0 commit comments

Comments
 (0)