PHP 7.4.33
Preview: Explorer.js Size: 3.08 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/cosmiconfig/dist/Explorer.js
"use strict";

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

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

var _ExplorerBase = require("./ExplorerBase");

var _readFile = require("./readFile");

var _cacheWrapper = require("./cacheWrapper");

var _getDirectory = require("./getDirectory");

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

class Explorer extends _ExplorerBase.ExplorerBase {
  constructor(options) {
    super(options);
  }

  async search(searchFrom = process.cwd()) {
    const startDirectory = await (0, _getDirectory.getDirectory)(searchFrom);
    const result = await this.searchFromDirectory(startDirectory);
    return result;
  }

  async searchFromDirectory(dir) {
    const absoluteDir = _path.default.resolve(process.cwd(), dir);

    const run = async () => {
      const result = await this.searchDirectory(absoluteDir);
      const nextDir = this.nextDirectoryToSearch(absoluteDir, result);

      if (nextDir) {
        return this.searchFromDirectory(nextDir);
      }

      const transformResult = await this.config.transform(result);
      return transformResult;
    };

    if (this.searchCache) {
      return (0, _cacheWrapper.cacheWrapper)(this.searchCache, absoluteDir, run);
    }

    return run();
  }

  async searchDirectory(dir) {
    for await (const place of this.config.searchPlaces) {
      const placeResult = await this.loadSearchPlace(dir, place);

      if (this.shouldSearchStopWithResult(placeResult) === true) {
        return placeResult;
      }
    } // config not found


    return null;
  }

  async loadSearchPlace(dir, place) {
    const filepath = _path.default.join(dir, place);

    const fileContents = await (0, _readFile.readFile)(filepath);
    const result = await this.createCosmiconfigResult(filepath, fileContents);
    return result;
  }

  async loadFileContent(filepath, content) {
    if (content === null) {
      return null;
    }

    if (content.trim() === '') {
      return undefined;
    }

    const loader = this.getLoaderEntryForFile(filepath);
    const loaderResult = await loader(filepath, content);
    return loaderResult;
  }

  async createCosmiconfigResult(filepath, content) {
    const fileContent = await this.loadFileContent(filepath, content);
    const result = this.loadedContentToCosmiconfigResult(filepath, fileContent);
    return result;
  }

  async load(filepath) {
    this.validateFilePath(filepath);

    const absoluteFilePath = _path.default.resolve(process.cwd(), filepath);

    const runLoad = async () => {
      const fileContents = await (0, _readFile.readFile)(absoluteFilePath, {
        throwNotFound: true
      });
      const result = await this.createCosmiconfigResult(absoluteFilePath, fileContents);
      const transformResult = await this.config.transform(result);
      return transformResult;
    };

    if (this.loadCache) {
      return (0, _cacheWrapper.cacheWrapper)(this.loadCache, absoluteFilePath, runLoad);
    }

    return runLoad();
  }

}

exports.Explorer = Explorer;
//# sourceMappingURL=Explorer.js.map

Directory Contents

Dirs: 0 × Files: 40
Name Size Perms Modified Actions
371 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
450 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
612 B lrw-r--r-- 2025-03-28 11:04:36
Edit Download
1.43 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
550 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
480 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
3.08 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
6.56 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.07 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1004 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
3.36 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
7.35 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
584 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
524 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
3.06 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
6.43 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
212 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
280 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
900 B lrw-r--r-- 2025-03-28 11:04:36
Edit Download
1.29 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
193 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
301 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
938 B lrw-r--r-- 2025-03-28 11:04:36
Edit Download
1.67 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.88 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.18 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
2.93 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
6.87 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
132 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
216 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.13 KB lrw-r--r-- 2025-03-28 11:04:36
Edit Download
2.68 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
295 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
385 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.29 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
2.62 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
635 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
684 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
113 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
89 B lrw-r--r-- 2025-03-28 11:04:37
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).