Current File : /home/tradevaly/www/node_modules/cosmiconfig/dist/Explorer.js.map
{"version":3,"sources":["../src/Explorer.ts"],"names":["Explorer","ExplorerBase","constructor","options","search","searchFrom","process","cwd","startDirectory","result","searchFromDirectory","dir","absoluteDir","path","resolve","run","searchDirectory","nextDir","nextDirectoryToSearch","transformResult","config","transform","searchCache","place","searchPlaces","placeResult","loadSearchPlace","shouldSearchStopWithResult","filepath","join","fileContents","createCosmiconfigResult","loadFileContent","content","trim","undefined","loader","getLoaderEntryForFile","loaderResult","fileContent","loadedContentToCosmiconfigResult","load","validateFilePath","absoluteFilePath","runLoad","throwNotFound","loadCache"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;AAGA,MAAMA,QAAN,SAAuBC,0BAAvB,CAAqD;AAC5CC,EAAAA,WAAW,CAACC,OAAD,EAA2B;AAC3C,UAAMA,OAAN;AACD;;AAEkB,QAANC,MAAM,CACjBC,UAAkB,GAAGC,OAAO,CAACC,GAAR,EADJ,EAEW;AAC5B,UAAMC,cAAc,GAAG,MAAM,gCAAaH,UAAb,CAA7B;AACA,UAAMI,MAAM,GAAG,MAAM,KAAKC,mBAAL,CAAyBF,cAAzB,CAArB;AAEA,WAAOC,MAAP;AACD;;AAEgC,QAAnBC,mBAAmB,CAACC,GAAD,EAA0C;AACzE,UAAMC,WAAW,GAAGC,cAAKC,OAAL,CAAaR,OAAO,CAACC,GAAR,EAAb,EAA4BI,GAA5B,CAApB;;AAEA,UAAMI,GAAG,GAAG,YAAwC;AAClD,YAAMN,MAAM,GAAG,MAAM,KAAKO,eAAL,CAAqBJ,WAArB,CAArB;AACA,YAAMK,OAAO,GAAG,KAAKC,qBAAL,CAA2BN,WAA3B,EAAwCH,MAAxC,CAAhB;;AAEA,UAAIQ,OAAJ,EAAa;AACX,eAAO,KAAKP,mBAAL,CAAyBO,OAAzB,CAAP;AACD;;AAED,YAAME,eAAe,GAAG,MAAM,KAAKC,MAAL,CAAYC,SAAZ,CAAsBZ,MAA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,WAAW,GAAG,MAAM,KAAKP,eAAL,CAAqBJ,QAArB,EAA+BK,OAA/B,CAA1B;AACA,UAAMxB,MAAM,GAAG,KAAK+B,gCAAL,CAAsCZ,QAAtC,EAAgDW,WAAhD,CAAf;AAEA,WAAO9B,MAAP;AACD;;AAEgB,QAAJgC,IAAI,CAACb,QAAD,EAA+C;AAC9D,SAAKc,gBAAL,CAAsBd,QAAtB;;AACA,UAAMe,gBAAgB,GAAG9B,cAAKC,OAAL,CAAaR,OAAO,CAACC,GAAR,EAAb,EAA4BqB,QAA5B,CAAzB;;AAEA,UAAMgB,OAAO,GAAG,YAAwC;AACtD,YAAMd,YAAY,GAAG,MAAM,wBAASa,gBAAT,EAA2B;AACpDE,QAAAA,aAAa,EAAE;AADqC,OAA3B,CAA3B;AAIA,YAAMpC,MAAM,GAAG,MAAM,KAAKsB,uBAAL,CACnBY,gBADmB,EAEnBb,YAFmB,CAArB;AAKA,YAAMX,eAAe,GAAG,MAAM,KAAKC,MAAL,CAAYC,SAAZ,CAAsBZ,MAAtB,CAA9B;AAEA,aAAOU,eAAP;AACD,KAbD;;AAeA,QAAI,KAAK2B,SAAT,EAAoB;AAClB,aAAO,gCAAa,KAAKA,SAAlB,EAA6BH,gBAA7B,EAA+CC,OAA/C,CAAP;AACD;;AAED,WAAOA,OAAO,EAAd;AACD;;AA/GkD","sourcesContent":["import path from 'path';\nimport { ExplorerBase } from './ExplorerBase';\nimport { readFile } from './readFile';\nimport { cacheWrapper } from './cacheWrapper';\nimport { getDirectory } from './getDirectory';\nimport { CosmiconfigResult, ExplorerOptions, LoadedFileContent } from './types';\n\nclass Explorer extends ExplorerBase<ExplorerOptions> {\n  public constructor(options: ExplorerOptions) {\n    super(options);\n  }\n\n  public async search(\n    searchFrom: string = process.cwd(),\n  ): Promise<CosmiconfigResult> {\n    const startDirectory = await getDirectory(searchFrom);\n    const result = await this.searchFromDirectory(startDirectory);\n\n    return result;\n  }\n\n  private async searchFromDirectory(dir: string): Promise<CosmiconfigResult> {\n    const absoluteDir = path.resolve(process.cwd(), dir);\n\n    const run = async (): Promise<CosmiconfigResult> => {\n      const result = await this.searchDirectory(absoluteDir);\n      const nextDir = this.nextDirectoryToSearch(absoluteDir, result);\n\n      if (nextDir) {\n        return this.searchFromDirectory(nextDir);\n      }\n\n      const transformResult = await this.config.transform(result);\n\n      return transformResult;\n    };\n\n    if (this.searchCache) {\n      return cacheWrapper(this.searchCache, absoluteDir, run);\n    }\n\n    return run();\n  }\n\n  private async searchDirectory(dir: string): Promise<CosmiconfigResult> {\n    for await (const place of this.config.searchPlaces) {\n      const placeResult = await this.loadSearchPlace(dir, place);\n\n      if (this.shouldSearchStopWithResult(placeResult) === true) {\n        return placeResult;\n      }\n    }\n\n    // config not found\n    return null;\n  }\n\n  private async loadSearchPlace(\n    dir: string,\n    place: string,\n  ): Promise<CosmiconfigResult> {\n    const filepath = path.join(dir, place);\n    const fileContents = await readFile(filepath);\n\n    const result = await this.createCosmiconfigResult(filepath, fileContents);\n\n    return result;\n  }\n\n  private async loadFileContent(\n    filepath: string,\n    content: string | null,\n  ): Promise<LoadedFileContent> {\n    if (content === null) {\n      return null;\n    }\n    if (content.trim() === '') {\n      return undefined;\n    }\n    const loader = this.getLoaderEntryForFile(filepath);\n    const loaderResult = await loader(filepath, content);\n    return loaderResult;\n  }\n\n  private async createCosmiconfigResult(\n    filepath: string,\n    content: string | null,\n  ): Promise<CosmiconfigResult> {\n    const fileContent = await this.loadFileContent(filepath, content);\n    const result = this.loadedContentToCosmiconfigResult(filepath, fileContent);\n\n    return result;\n  }\n\n  public async load(filepath: string): Promise<CosmiconfigResult> {\n    this.validateFilePath(filepath);\n    const absoluteFilePath = path.resolve(process.cwd(), filepath);\n\n    const runLoad = async (): Promise<CosmiconfigResult> => {\n      const fileContents = await readFile(absoluteFilePath, {\n        throwNotFound: true,\n      });\n\n      const result = await this.createCosmiconfigResult(\n        absoluteFilePath,\n        fileContents,\n      );\n\n      const transformResult = await this.config.transform(result);\n\n      return transformResult;\n    };\n\n    if (this.loadCache) {\n      return cacheWrapper(this.loadCache, absoluteFilePath, runLoad);\n    }\n\n    return runLoad();\n  }\n}\n\nexport { Explorer };\n"],"file":"Explorer.js"}