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 <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
ecbae568b7
commit
fea1e05ba5
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
@ -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'));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user