@visulima/tsconfig
Version:
Find and/or parse the tsconfig.json file from a directory path.
2 lines (1 loc) • 1.28 kB
JavaScript
var h=Object.defineProperty;var f=(n,o)=>h(n,"name",{value:o,configurable:!0});import{findUp as s,findUpSync as r}from"@visulima/fs";import{NotFoundError as a}from"@visulima/fs/error";import{readTsConfig as p}from"./implicitBaseUrlSymbol-CMaKZ6En.js";var d=Object.defineProperty,l=f((n,o)=>d(n,"name",{value:o,configurable:!0}),"f");const g=new Map,w=l(async(n,o={})=>{const e=o.configFileName??"tsconfig.json";let c=await s(e,{...n&&{cwd:n},type:"file"});if(c||(c=await s("jsconfig.json",{...n&&{cwd:n},type:"file"})),!c)throw new a(`No such file or directory, for '${e}' or 'jsconfig.json' found.`);const i=o.cache&&typeof o.cache!="boolean"?o.cache:g;if(o.cache&&i.has(c))return i.get(c);const t={config:p(c,{tscCompatible:o.tscCompatible}),path:c};return o.cache&&i.set(c,t),t},"findTsConfig"),C=l((n,o={})=>{const e=o.configFileName??"tsconfig.json";let c=r(e,{...n&&{cwd:n},type:"file"});if(c||(c=r("jsconfig.json",{...n&&{cwd:n},type:"file"})),!c)throw new a(`No such file or directory, for '${e}' or 'jsconfig.json' found.`);const i=o.cache&&typeof o.cache!="boolean"?o.cache:g;if(o.cache&&i.has(c))return i.get(c);const t={config:p(c,{tscCompatible:o.tscCompatible}),path:c};return o.cache&&i.set(c,t),t},"findTsConfigSync");export{w as findTsConfig,C as findTsConfigSync};