Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module: allow monkey-patching internal fs binding #39711

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
module: allow monkey-patching internal fs binding
  • Loading branch information
zcbenz committed Aug 9, 2021
commit 94782228168d30674ba6cc8cdc9319e83ab4a6c9
4 changes: 2 additions & 2 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const fs = require('fs');
const internalFS = require('internal/fs/utils');
const path = require('path');
const { sep } = path;
const { internalModuleStat } = internalBinding('fs');
const internalFsBinding = internalBinding('fs');
const packageJsonReader = require('internal/modules/package_json_reader');
const { safeGetenv } = internalBinding('credentials');
const {
Expand Down Expand Up @@ -154,7 +154,7 @@ function stat(filename) {
const result = statCache.get(filename);
if (result !== undefined) return result;
}
const result = internalModuleStat(filename);
const result = internalFsBinding.internalModuleStat(filename);
if (statCache !== null && result >= 0) {
// Only set cache when `internalModuleStat(filename)` succeeds.
statCache.set(filename, result);
Expand Down
7 changes: 3 additions & 4 deletions lib/internal/modules/package_json_reader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { SafeMap } = primordials;
const { internalModuleReadJSON } = internalBinding('fs');
const internalFsBinding = internalBinding('fs');
const { pathToFileURL } = require('url');
const { toNamespacedPath } = require('path');

Expand All @@ -18,9 +18,8 @@ function read(jsonPath) {
return cache.get(jsonPath);
}

const { 0: string, 1: containsKeys } = internalModuleReadJSON(
toNamespacedPath(jsonPath)
);
const { 0: string, 1: containsKeys } =
internalFsBinding.internalModuleReadJSON(toNamespacedPath(jsonPath));
const result = { string, containsKeys };
const { getOptionValue } = require('internal/options');
if (string !== undefined) {
Expand Down