fs: export realpathCacheKey
from internal/fs
Move the internally defined symbol `fs.realpathCacheKey` to the internal fs module, where it’s more appropriate. The symbol was recently added in c084287a608ef, but since `internal/fs` is only available in the v7.x branch, this needs to be a separate follow-up change. PR-URL: https://github.com/nodejs/node/pull/8862 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
2e2887579f
commit
5dea1e2a5d
@ -1463,10 +1463,6 @@ function encodeRealpathResult(result, options, err) {
|
||||
}
|
||||
}
|
||||
|
||||
// This is removed from the fs exports in lib/module.js in order to make
|
||||
// sure that this stays internal.
|
||||
const realpathCacheKey = fs.realpathCacheKey = Symbol('realpathCacheKey');
|
||||
|
||||
fs.realpathSync = function realpathSync(p, options) {
|
||||
options = getOptions(options, {});
|
||||
nullCheck(p);
|
||||
@ -1476,7 +1472,7 @@ fs.realpathSync = function realpathSync(p, options) {
|
||||
|
||||
const seenLinks = {};
|
||||
const knownHard = {};
|
||||
const cache = options[realpathCacheKey];
|
||||
const cache = options[internalFS.realpathCacheKey];
|
||||
const original = p;
|
||||
|
||||
const maybeCachedResult = cache && cache.get(p);
|
||||
|
@ -96,3 +96,5 @@ SyncWriteStream.prototype.destroy = function() {
|
||||
};
|
||||
|
||||
exports.SyncWriteStream = SyncWriteStream;
|
||||
|
||||
exports.realpathCacheKey = Symbol('realpathCacheKey');
|
||||
|
@ -6,6 +6,7 @@ const internalModule = require('internal/module');
|
||||
const vm = require('vm');
|
||||
const assert = require('assert').ok;
|
||||
const fs = require('fs');
|
||||
const internalFS = require('internal/fs');
|
||||
const path = require('path');
|
||||
const internalModuleReadFile = process.binding('fs').internalModuleReadFile;
|
||||
const internalModuleStat = process.binding('fs').internalModuleStat;
|
||||
@ -113,9 +114,6 @@ function tryPackage(requestPath, exts, isMain) {
|
||||
// Set to an empty Map to reset.
|
||||
const realpathCache = new Map();
|
||||
|
||||
const realpathCacheKey = fs.realpathCacheKey;
|
||||
delete fs.realpathCacheKey;
|
||||
|
||||
// check if the file exists and is not a directory
|
||||
// if using --preserve-symlinks and isMain is false,
|
||||
// keep symlinks intact, otherwise resolve to the
|
||||
@ -130,7 +128,7 @@ function tryFile(requestPath, isMain) {
|
||||
|
||||
function toRealPath(requestPath) {
|
||||
return fs.realpathSync(requestPath, {
|
||||
[realpathCacheKey]: realpathCache
|
||||
[internalFS.realpathCacheKey]: realpathCache
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user