Skip to content

Commit

Permalink
module: rename internalModuleReadFile to internalModuleReadJSON
Browse files Browse the repository at this point in the history
PR-URL: nodejs#17084
Fixes: nodejs#17076
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
jdalton authored and Trott committed Nov 28, 2017
1 parent ecbae56 commit fea1e05
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value>& args) {
static void InternalModuleReadJSON(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
uv_loop_t* loop = env->event_loop();

Expand Down Expand Up @@ -1478,7 +1478,7 @@ void InitFs(Local<Object> 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);
Expand Down
10 changes: 5 additions & 5 deletions test/parallel/test-module-binding.js
Original file line number Diff line number Diff line change
@@ -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'));
}

0 comments on commit fea1e05

Please sign in to comment.