| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,7 +79,13 @@ const { | |||
| 79 | 79 | maybeCacheSourceMap, | |
| 80 | 80 | } = require('internal/source_map/source_map_cache'); | |
| 81 | 81 | const { pathToFileURL, fileURLToPath, isURLInstance } = require('internal/url'); | |
| 82 | - const { deprecate, kEmptyObject, filterOwnProperties, setOwnProperty } = require('internal/util'); | ||
| 82 | + const { | ||
| 83 | + deprecate, | ||
| 84 | + emitExperimentalWarning, | ||
| 85 | + kEmptyObject, | ||
| 86 | + filterOwnProperties, | ||
| 87 | + setOwnProperty, | ||
| 88 | + } = require('internal/util'); | ||
| 83 | 89 | const vm = require('vm'); | |
| 84 | 90 | const assert = require('internal/assert'); | |
| 85 | 91 | const fs = require('fs'); | |
@@ -162,6 +168,18 @@ function stat(filename) { | |||
| 162 | 168 | return result; | |
| 163 | 169 | } | |
| 164 | 170 | ||
| 171 | + let _stat = stat; | ||
| 172 | + ObjectDefineProperty(Module, '_stat', { | ||
| 173 | + __proto__: null, | ||
| 174 | + get() { return _stat; }, | ||
| 175 | + set(stat) { | ||
| 176 | + emitExperimentalWarning('Module._stat'); | ||
| 177 | + _stat = stat; | ||
| 178 | + return true; | ||
| 179 | + }, | ||
| 180 | + configurable: true, | ||
| 181 | + }); | ||
| 182 | + | ||
| 165 | 183 | function updateChildren(parent, child, scan) { | |
| 166 | 184 | const children = parent?.children; | |
| 167 | 185 | if (children && !(scan && ArrayPrototypeIncludes(children, child))) | |
@@ -328,6 +346,18 @@ function readPackage(requestPath) { | |||
| 328 | 346 | } | |
| 329 | 347 | } | |
| 330 | 348 | ||
| 349 | + let _readPackage = readPackage; | ||
| 350 | + ObjectDefineProperty(Module, '_readPackage', { | ||
| 351 | + __proto__: null, | ||
| 352 | + get() { return _readPackage; }, | ||
| 353 | + set(readPackage) { | ||
| 354 | + emitExperimentalWarning('Module._readPackage'); | ||
| 355 | + _readPackage = readPackage; | ||
| 356 | + return true; | ||
| 357 | + }, | ||
| 358 | + configurable: true, | ||
| 359 | + }); | ||
| 360 | + | ||
| 331 | 361 | function readPackageScope(checkPath) { | |
| 332 | 362 | const rootSeparatorIndex = StringPrototypeIndexOf(checkPath, sep); | |
| 333 | 363 | let separatorIndex; | |
@@ -336,7 +366,7 @@ function readPackageScope(checkPath) { | |||
| 336 | 366 | checkPath = StringPrototypeSlice(checkPath, 0, separatorIndex); | |
| 337 | 367 | if (StringPrototypeEndsWith(checkPath, sep + 'node_modules')) | |
| 338 | 368 | return false; | |
| 339 | - const pjson = readPackage(checkPath + sep); | ||
| 369 | + const pjson = _readPackage(checkPath + sep); | ||
| 340 | 370 | if (pjson) return { | |
| 341 | 371 | data: pjson, | |
| 342 | 372 | path: checkPath, | |
@@ -346,7 +376,7 @@ function readPackageScope(checkPath) { | |||
| 346 | 376 | } | |
| 347 | 377 | ||
| 348 | 378 | function tryPackage(requestPath, exts, isMain, originalPath) { | |
| 349 | - const pkg = readPackage(requestPath)?.main; | ||
| 379 | + const pkg = _readPackage(requestPath)?.main; | ||
| 350 | 380 | ||
| 351 | 381 | if (!pkg) { | |
| 352 | 382 | return tryExtensions(path.resolve(requestPath, 'index'), exts, isMain); | |
@@ -392,7 +422,7 @@ const realpathCache = new SafeMap(); | |||
| 392 | 422 | // keep symlinks intact, otherwise resolve to the | |
| 393 | 423 | // absolute realpath. | |
| 394 | 424 | function tryFile(requestPath, isMain) { | |
| 395 | - const rc = stat(requestPath); | ||
| 425 | + const rc = _stat(requestPath); | ||
| 396 | 426 | if (rc !== 0) return; | |
| 397 | 427 | if (preserveSymlinks && !isMain) { | |
| 398 | 428 | return path.resolve(requestPath); | |
@@ -486,7 +516,7 @@ function resolveExports(nmPath, request) { | |||
| 486 | 516 | if (!name) | |
| 487 | 517 | return; | |
| 488 | 518 | const pkgPath = path.resolve(nmPath, name); | |
| 489 | - const pkg = readPackage(pkgPath); | ||
| 519 | + const pkg = _readPackage(pkgPath); | ||
| 490 | 520 | if (pkg?.exports != null) { | |
| 491 | 521 | try { | |
| 492 | 522 | return finalizeEsmResolution(packageExportsResolve( | |
@@ -526,7 +556,7 @@ Module._findPath = function(request, paths, isMain) { | |||
| 526 | 556 | for (let i = 0; i < paths.length; i++) { | |
| 527 | 557 | // Don't search further if path doesn't exist | |
| 528 | 558 | const curPath = paths[i]; | |
| 529 | - if (curPath && stat(curPath) < 1) continue; | ||
| 559 | + if (curPath && _stat(curPath) < 1) continue; | ||
| 530 | 560 | ||
| 531 | 561 | if (!absoluteRequest) { | |
| 532 | 562 | const exportsResolved = resolveExports(curPath, request); | |
@@ -537,7 +567,7 @@ Module._findPath = function(request, paths, isMain) { | |||
| 537 | 567 | const basePath = path.resolve(curPath, request); | |
| 538 | 568 | let filename; | |
| 539 | 569 | ||
| 540 | - const rc = stat(basePath); | ||
| 570 | + const rc = _stat(basePath); | ||
| 541 | 571 | if (!trailingSlash) { | |
| 542 | 572 | if (rc === 0) { // File. | |
| 543 | 573 | if (!isMain) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments