aboutsummaryrefslogtreecommitdiff
path: root/node_modules/jest-resolve/build/fileWalkers.js
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
committerJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
commit080c5819d87b933816d724a83f3bf4f1686770a7 (patch)
tree4a2ccc68b27edf7d4cbc586c932cc7542b655e19 /node_modules/jest-resolve/build/fileWalkers.js
parent5ac7049a9d30733165cc212dee308163c2a14644 (diff)
parentd003b82235a9329f912522a2f70aa950dfce4998 (diff)
downloadLYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.tar.gz
LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.zip
Merge branch 'master' of https://github.com/JoelHMikael/FoodJS
Updating remote changes
Diffstat (limited to 'node_modules/jest-resolve/build/fileWalkers.js')
-rw-r--r--node_modules/jest-resolve/build/fileWalkers.js214
1 files changed, 214 insertions, 0 deletions
diff --git a/node_modules/jest-resolve/build/fileWalkers.js b/node_modules/jest-resolve/build/fileWalkers.js
new file mode 100644
index 0000000..d621fcf
--- /dev/null
+++ b/node_modules/jest-resolve/build/fileWalkers.js
@@ -0,0 +1,214 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports.clearFsCache = clearFsCache;
+exports.findClosestPackageJson = findClosestPackageJson;
+exports.isDirectory = isDirectory;
+exports.isFile = isFile;
+exports.readPackageCached = readPackageCached;
+exports.realpathSync = realpathSync;
+
+function _path() {
+ const data = require('path');
+
+ _path = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function fs() {
+ const data = _interopRequireWildcard(require('graceful-fs'));
+
+ fs = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _jestUtil() {
+ const data = require('jest-util');
+
+ _jestUtil = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _getRequireWildcardCache(nodeInterop) {
+ if (typeof WeakMap !== 'function') return null;
+ var cacheBabelInterop = new WeakMap();
+ var cacheNodeInterop = new WeakMap();
+ return (_getRequireWildcardCache = function (nodeInterop) {
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
+ })(nodeInterop);
+}
+
+function _interopRequireWildcard(obj, nodeInterop) {
+ if (!nodeInterop && obj && obj.__esModule) {
+ return obj;
+ }
+ if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
+ return {default: obj};
+ }
+ var cache = _getRequireWildcardCache(nodeInterop);
+ if (cache && cache.has(obj)) {
+ return cache.get(obj);
+ }
+ var newObj = {};
+ var hasPropertyDescriptor =
+ Object.defineProperty && Object.getOwnPropertyDescriptor;
+ for (var key in obj) {
+ if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
+ var desc = hasPropertyDescriptor
+ ? Object.getOwnPropertyDescriptor(obj, key)
+ : null;
+ if (desc && (desc.get || desc.set)) {
+ Object.defineProperty(newObj, key, desc);
+ } else {
+ newObj[key] = obj[key];
+ }
+ }
+ }
+ newObj.default = obj;
+ if (cache) {
+ cache.set(obj, newObj);
+ }
+ return newObj;
+}
+
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+function clearFsCache() {
+ checkedPaths.clear();
+ checkedRealpathPaths.clear();
+ packageContents.clear();
+}
+
+var IPathType;
+
+(function (IPathType) {
+ IPathType[(IPathType['FILE'] = 1)] = 'FILE';
+ IPathType[(IPathType['DIRECTORY'] = 2)] = 'DIRECTORY';
+ IPathType[(IPathType['OTHER'] = 3)] = 'OTHER';
+})(IPathType || (IPathType = {}));
+
+const checkedPaths = new Map();
+
+function statSyncCached(path) {
+ const result = checkedPaths.get(path);
+
+ if (result != null) {
+ return result;
+ }
+
+ let stat;
+
+ try {
+ // @ts-expect-error TS2554 - throwIfNoEntry is only available in recent version of node, but inclusion of the option is a backward compatible no-op.
+ stat = fs().statSync(path, {
+ throwIfNoEntry: false
+ });
+ } catch (e) {
+ if (!(e && (e.code === 'ENOENT' || e.code === 'ENOTDIR'))) {
+ throw e;
+ }
+ }
+
+ if (stat) {
+ if (stat.isFile() || stat.isFIFO()) {
+ checkedPaths.set(path, IPathType.FILE);
+ return IPathType.FILE;
+ } else if (stat.isDirectory()) {
+ checkedPaths.set(path, IPathType.DIRECTORY);
+ return IPathType.DIRECTORY;
+ }
+ }
+
+ checkedPaths.set(path, IPathType.OTHER);
+ return IPathType.OTHER;
+}
+
+const checkedRealpathPaths = new Map();
+
+function realpathCached(path) {
+ let result = checkedRealpathPaths.get(path);
+
+ if (result != null) {
+ return result;
+ }
+
+ result = (0, _jestUtil().tryRealpath)(path);
+ checkedRealpathPaths.set(path, result);
+
+ if (path !== result) {
+ // also cache the result in case it's ever referenced directly - no reason to `realpath` that as well
+ checkedRealpathPaths.set(result, result);
+ }
+
+ return result;
+}
+
+const packageContents = new Map();
+
+function readPackageCached(path) {
+ let result = packageContents.get(path);
+
+ if (result != null) {
+ return result;
+ }
+
+ result = JSON.parse(fs().readFileSync(path, 'utf8'));
+ packageContents.set(path, result);
+ return result;
+} // adapted from
+// https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js
+// to use cached `fs` calls
+
+function findClosestPackageJson(start) {
+ let dir = (0, _path().resolve)('.', start);
+
+ if (!isDirectory(dir)) {
+ dir = (0, _path().dirname)(dir);
+ }
+
+ while (true) {
+ const pkgJsonFile = (0, _path().resolve)(dir, './package.json');
+ const hasPackageJson = isFile(pkgJsonFile);
+
+ if (hasPackageJson) {
+ return pkgJsonFile;
+ }
+
+ const prevDir = dir;
+ dir = (0, _path().dirname)(dir);
+
+ if (prevDir === dir) {
+ return undefined;
+ }
+ }
+}
+/*
+ * helper functions
+ */
+
+function isFile(file) {
+ return statSyncCached(file) === IPathType.FILE;
+}
+
+function isDirectory(dir) {
+ return statSyncCached(dir) === IPathType.DIRECTORY;
+}
+
+function realpathSync(file) {
+ return realpathCached(file);
+}