PHP 8.2.30
Preview: ExplorerBase.js Size: 3.36 KB
/home/byroehnu/easepay.easetack.com/node_modules/cosmiconfig/dist/ExplorerBase.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ExplorerBase = void 0;
exports.getExtensionDescription = getExtensionDescription;

var _path = _interopRequireDefault(require("path"));

var _loaders = require("./loaders");

var _getPropertyByPath = require("./getPropertyByPath");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

class ExplorerBase {
  constructor(options) {
    if (options.cache === true) {
      this.loadCache = new Map();
      this.searchCache = new Map();
    }

    this.config = options;
    this.validateConfig();
  }

  clearLoadCache() {
    if (this.loadCache) {
      this.loadCache.clear();
    }
  }

  clearSearchCache() {
    if (this.searchCache) {
      this.searchCache.clear();
    }
  }

  clearCaches() {
    this.clearLoadCache();
    this.clearSearchCache();
  }

  validateConfig() {
    const config = this.config;
    config.searchPlaces.forEach(place => {
      const loaderKey = _path.default.extname(place) || 'noExt';
      const loader = config.loaders[loaderKey];

      if (!loader) {
        throw new Error(`No loader specified for ${getExtensionDescription(place)}, so searchPlaces item "${place}" is invalid`);
      }

      if (typeof loader !== 'function') {
        throw new Error(`loader for ${getExtensionDescription(place)} is not a function (type provided: "${typeof loader}"), so searchPlaces item "${place}" is invalid`);
      }
    });
  }

  shouldSearchStopWithResult(result) {
    if (result === null) return false;
    if (result.isEmpty && this.config.ignoreEmptySearchPlaces) return false;
    return true;
  }

  nextDirectoryToSearch(currentDir, currentResult) {
    if (this.shouldSearchStopWithResult(currentResult)) {
      return null;
    }

    const nextDir = nextDirUp(currentDir);

    if (nextDir === currentDir || currentDir === this.config.stopDir) {
      return null;
    }

    return nextDir;
  }

  loadPackageProp(filepath, content) {
    const parsedContent = _loaders.loaders.loadJson(filepath, content);

    const packagePropValue = (0, _getPropertyByPath.getPropertyByPath)(parsedContent, this.config.packageProp);
    return packagePropValue || null;
  }

  getLoaderEntryForFile(filepath) {
    if (_path.default.basename(filepath) === 'package.json') {
      const loader = this.loadPackageProp.bind(this);
      return loader;
    }

    const loaderKey = _path.default.extname(filepath) || 'noExt';
    const loader = this.config.loaders[loaderKey];

    if (!loader) {
      throw new Error(`No loader specified for ${getExtensionDescription(filepath)}`);
    }

    return loader;
  }

  loadedContentToCosmiconfigResult(filepath, loadedContent) {
    if (loadedContent === null) {
      return null;
    }

    if (loadedContent === undefined) {
      return {
        filepath,
        config: undefined,
        isEmpty: true
      };
    }

    return {
      config: loadedContent,
      filepath
    };
  }

  validateFilePath(filepath) {
    if (!filepath) {
      throw new Error('load must pass a non-empty string');
    }
  }

}

exports.ExplorerBase = ExplorerBase;

function nextDirUp(dir) {
  return _path.default.dirname(dir);
}

function getExtensionDescription(filepath) {
  const ext = _path.default.extname(filepath);

  return ext ? `extension "${ext}"` : 'files without extensions';
}
//# sourceMappingURL=ExplorerBase.js.map

Directory Contents

Dirs: 0 × Files: 41

Name Size Perms Modified Actions
127 B lr--r--r-- 2026-03-14 01:49:20
Edit Download
371 B lrw-r--r-- 2026-02-28 00:28:50
Edit Download
450 B lrw-r--r-- 2026-02-28 00:28:08
Edit Download
612 B lrw-r--r-- 2026-02-28 00:26:44
Edit Download
1.43 KB lrw-r--r-- 2026-02-28 00:28:12
Edit Download
550 B lrw-r--r-- 2026-02-28 00:28:52
Edit Download
480 B lrw-r--r-- 2026-02-28 00:28:16
Edit Download
3.08 KB lrw-r--r-- 2026-02-28 00:26:54
Edit Download
6.56 KB lrw-r--r-- 2026-02-28 00:28:20
Edit Download
1.07 KB lrw-r--r-- 2026-02-28 00:28:54
Edit Download
1004 B lrw-r--r-- 2026-02-28 00:28:24
Edit Download
3.36 KB lrw-r--r-- 2026-02-28 00:27:04
Edit Download
7.35 KB lrw-r--r-- 2026-02-28 00:28:26
Edit Download
584 B lrw-r--r-- 2026-02-28 00:28:56
Edit Download
524 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
3.06 KB lrw-r--r-- 2026-02-28 00:27:14
Edit Download
6.43 KB lrw-r--r-- 2026-02-28 00:28:28
Edit Download
212 B lrw-r--r-- 2026-02-28 00:28:58
Edit Download
280 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
900 B lrw-r--r-- 2026-02-28 00:27:24
Edit Download
1.29 KB lrw-r--r-- 2026-02-28 00:28:30
Edit Download
193 B lrw-r--r-- 2026-02-28 00:28:58
Edit Download
301 B lrw-r--r-- 2026-02-28 00:28:32
Edit Download
938 B lrw-r--r-- 2026-02-28 00:27:32
Edit Download
1.67 KB lrw-r--r-- 2026-02-28 00:28:34
Edit Download
1.88 KB lrw-r--r-- 2026-02-28 00:28:58
Edit Download
1.18 KB lrw-r--r-- 2026-02-28 00:28:36
Edit Download
2.93 KB lrw-r--r-- 2026-02-28 00:27:38
Edit Download
6.87 KB lrw-r--r-- 2026-02-28 00:28:38
Edit Download
132 B lrw-r--r-- 2026-02-28 00:28:58
Edit Download
216 B lrw-r--r-- 2026-02-28 00:28:38
Edit Download
1.13 KB lrw-r--r-- 2026-02-28 00:27:44
Edit Download
2.68 KB lrw-r--r-- 2026-02-28 00:28:40
Edit Download
295 B lrw-r--r-- 2026-02-28 00:29:00
Edit Download
385 B lrw-r--r-- 2026-02-28 00:28:42
Edit Download
1.29 KB lrw-r--r-- 2026-02-28 00:27:52
Edit Download
2.62 KB lrw-r--r-- 2026-02-28 00:28:42
Edit Download
635 B lrw-r--r-- 2026-02-28 00:29:00
Edit Download
684 B lrw-r--r-- 2026-02-28 00:28:44
Edit Download
113 B lrw-r--r-- 2026-02-28 00:28:00
Edit Download
89 B lrw-r--r-- 2026-02-28 00:28:46
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).