Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-tsconfig

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-tsconfig - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

6

dist/index.js

@@ -1,3 +0,3 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var R=require("path"),G=require("fs");function q(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var d=q(R),O=q(G);function T(r){const t=/^\\\\\?\\/.test(r),n=/[^\u0000-\u0080]+/.test(r);return t||n?r:r.replace(/\\/g,"/")}function F(r,t){for(;;){const n=d.default.join(r,t);if(O.default.existsSync(n))return T(n);const e=d.default.dirname(r);if(e===r)return;r=e}}function K(r,t){t===void 0&&(t=!1);var n=r.length,e=0,s="",a=0,o=16,u=0,c=0,p=0,C=0,f=0;function A(i,b){for(var v=0,k=0;v<i||!b;){var h=r.charCodeAt(e);if(h>=48&&h<=57)k=k*16+h-48;else if(h>=65&&h<=70)k=k*16+h-65+10;else if(h>=97&&h<=102)k=k*16+h-97+10;else break;e++,v++}return v<i&&(k=-1),k}function V(i){e=i,s="",a=0,o=16,f=0}function $(){var i=e;if(r.charCodeAt(e)===48)e++;else for(e++;e<r.length&&y(r.charCodeAt(e));)e++;if(e<r.length&&r.charCodeAt(e)===46)if(e++,e<r.length&&y(r.charCodeAt(e)))for(e++;e<r.length&&y(r.charCodeAt(e));)e++;else return f=3,r.substring(i,e);var b=e;if(e<r.length&&(r.charCodeAt(e)===69||r.charCodeAt(e)===101))if(e++,(e<r.length&&r.charCodeAt(e)===43||r.charCodeAt(e)===45)&&e++,e<r.length&&y(r.charCodeAt(e))){for(e++;e<r.length&&y(r.charCodeAt(e));)e++;b=e}else f=3;return r.substring(i,b)}function E(){for(var i="",b=e;;){if(e>=n){i+=r.substring(b,e),f=2;break}var v=r.charCodeAt(e);if(v===34){i+=r.substring(b,e),e++;break}if(v===92){if(i+=r.substring(b,e),e++,e>=n){f=2;break}var k=r.charCodeAt(e++);switch(k){case 34:i+='"';break;case 92:i+="\\";break;case 47:i+="/";break;case 98:i+="\b";break;case 102:i+="\f";break;case 110:i+=`
`;break;case 114:i+="\r";break;case 116:i+=" ";break;case 117:var h=A(4,!0);h>=0?i+=String.fromCharCode(h):f=4;break;default:f=5}b=e;continue}if(v>=0&&v<=31)if(S(v)){i+=r.substring(b,e),f=2;break}else f=6;e++}return i}function P(){if(s="",f=0,a=e,c=u,C=p,e>=n)return a=n,o=17;var i=r.charCodeAt(e);if(U(i)){do e++,s+=String.fromCharCode(i),i=r.charCodeAt(e);while(U(i));return o=15}if(S(i))return e++,s+=String.fromCharCode(i),i===13&&r.charCodeAt(e)===10&&(e++,s+=`
`),u++,p=e,o=14;switch(i){case 123:return e++,o=1;case 125:return e++,o=2;case 91:return e++,o=3;case 93:return e++,o=4;case 58:return e++,o=6;case 44:return e++,o=5;case 34:return e++,s=E(),o=10;case 47:var b=e-1;if(r.charCodeAt(e+1)===47){for(e+=2;e<n&&!S(r.charCodeAt(e));)e++;return s=r.substring(b,e),o=12}if(r.charCodeAt(e+1)===42){e+=2;for(var v=n-1,k=!1;e<v;){var h=r.charCodeAt(e);if(h===42&&r.charCodeAt(e+1)===47){e+=2,k=!0;break}e++,S(h)&&(h===13&&r.charCodeAt(e)===10&&e++,u++,p=e)}return k||(e++,f=1),s=r.substring(b,e),o=13}return s+=String.fromCharCode(i),e++,o=16;case 45:if(s+=String.fromCharCode(i),e++,e===n||!y(r.charCodeAt(e)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return s+=$(),o=11;default:for(;e<n&&m(i);)e++,i=r.charCodeAt(e);if(a!==e){switch(s=r.substring(a,e),s){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return s+=String.fromCharCode(i),e++,o=16}}function m(i){if(U(i)||S(i))return!1;switch(i){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function l(){var i;do i=P();while(i>=12&&i<=15);return i}return{setPosition:V,getPosition:function(){return e},scan:t?l:P,getToken:function(){return o},getTokenValue:function(){return s},getTokenOffset:function(){return a},getTokenLength:function(){return e-a},getTokenStartLine:function(){return c},getTokenStartCharacter:function(){return a-C},getTokenError:function(){return f}}}function U(r){return r===32||r===9||r===11||r===12||r===160||r===5760||r>=8192&&r<=8203||r===8239||r===8287||r===12288||r===65279}function S(r){return r===10||r===13||r===8232||r===8233}function y(r){return r>=48&&r<=57}var D;(function(r){r.DEFAULT={allowTrailingComma:!1}})(D||(D={}));function Q(r,t,n){t===void 0&&(t=[]),n===void 0&&(n=D.DEFAULT);var e=null,s=[],a=[];function o(c){Array.isArray(s)?s.push(c):e!==null&&(s[e]=c)}var u={onObjectBegin:function(){var c={};o(c),a.push(s),s=c,e=null},onObjectProperty:function(c){e=c},onObjectEnd:function(){s=a.pop()},onArrayBegin:function(){var c=[];o(c),a.push(s),s=c,e=null},onArrayEnd:function(){s=a.pop()},onLiteralValue:o,onError:function(c,p,C){t.push({error:c,offset:p,length:C})}};return X(r,u,n),s[0]}function X(r,t,n){n===void 0&&(n=D.DEFAULT);var e=K(r,!1);function s(g){return g?function(){return g(e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return!0}}function a(g){return g?function(w){return g(w,e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return!0}}var o=s(t.onObjectBegin),u=a(t.onObjectProperty),c=s(t.onObjectEnd),p=s(t.onArrayBegin),C=s(t.onArrayEnd),f=a(t.onLiteralValue),A=a(t.onSeparator),V=s(t.onComment),$=a(t.onError),E=n&&n.disallowComments,P=n&&n.allowTrailingComma;function m(){for(;;){var g=e.scan();switch(e.getTokenError()){case 4:l(14);break;case 5:l(15);break;case 3:l(13);break;case 1:E||l(11);break;case 2:l(12);break;case 6:l(16);break}switch(g){case 12:case 13:E?l(10):V();break;case 16:l(1);break;case 15:case 14:break;default:return g}}}function l(g,w,_){if(w===void 0&&(w=[]),_===void 0&&(_=[]),$(g),w.length+_.length>0)for(var L=e.getToken();L!==17;){if(w.indexOf(L)!==-1){m();break}else if(_.indexOf(L)!==-1)break;L=m()}}function i(g){var w=e.getTokenValue();return g?f(w):u(w),m(),!0}function b(){switch(e.getToken()){case 11:var g=e.getTokenValue(),w=Number(g);isNaN(w)&&(l(2),w=0),f(w);break;case 7:f(null);break;case 8:f(!0);break;case 9:f(!1);break;default:return!1}return m(),!0}function v(){return e.getToken()!==10?(l(3,[],[2,5]),!1):(i(!1),e.getToken()===6?(A(":"),m(),B()||l(4,[],[2,5])):l(5,[],[2,5]),!0)}function k(){o(),m();for(var g=!1;e.getToken()!==2&&e.getToken()!==17;){if(e.getToken()===5){if(g||l(4,[],[]),A(","),m(),e.getToken()===2&&P)break}else g&&l(6,[],[]);v()||l(4,[],[2,5]),g=!0}return c(),e.getToken()!==2?l(7,[2],[]):m(),!0}function h(){p(),m();for(var g=!1;e.getToken()!==4&&e.getToken()!==17;){if(e.getToken()===5){if(g||l(4,[],[]),A(","),m(),e.getToken()===4&&P)break}else g&&l(6,[],[]);B()||l(4,[],[4,5]),g=!0}return C(),e.getToken()!==4?l(8,[4],[]):m(),!0}function B(){switch(e.getToken()){case 3:return h();case 1:return k();case 10:return i(!0);default:return b()}}return m(),e.getToken()===17?n.allowEmptyContent?!0:(l(4,[],[]),!1):B()?(e.getToken()!==17&&l(9,[],[]),!0):(l(4,[],[]),!1)}var Y=Q;const W=/^\.{1,2}(\/.*)?$/,M=r=>T(W.test(r)?r:`./${r}`),N=r=>O.default.existsSync(r),Z=r=>{try{return JSON.parse(r)}catch{}};function x(r,t){let n=r;if(n===".."&&(n+="/tsconfig.json"),n.startsWith(".")){let e=d.default.resolve(t,n);if(N(e)&&O.default.statSync(e).isFile()||!e.endsWith(".json")&&(e+=".json",N(e)))return e}else{let e=F(t,d.default.join("node_modules",n));if(e){if(O.default.statSync(e).isDirectory()){const s=d.default.join(e,"package.json");if(N(s)){const a=Z(O.default.readFileSync(s,"utf8"));a&&"tsconfig"in a?e=d.default.join(e,a.tsconfig):e=d.default.join(e,"tsconfig.json")}else e=d.default.join(e,"tsconfig.json");if(N(e))return e}else if(e.endsWith(".json"))return e}if(!n.endsWith(".json")&&(n+=".json",e=F(t,d.default.join("node_modules",n)),e))return e}throw new Error(`File '${r}' not found.`)}var ee=Object.defineProperty,re=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,te=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable,z=(r,t,n)=>t in r?ee(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,j=(r,t)=>{for(var n in t||(t={}))te.call(t,n)&&z(r,n,t[n]);if(I)for(var n of I(t))ae.call(t,n)&&z(r,n,t[n]);return r},oe=(r,t)=>re(r,ne(t));function J(r){var t;let n;try{n=O.default.realpathSync(r)}catch{throw new Error(`Cannot resolve tsconfig at path: ${r}`)}const e=d.default.dirname(n),s=O.default.readFileSync(n,"utf8").trim();let a={};if(s&&(a=Y(s),!a||typeof a!="object"))throw new SyntaxError(`Failed to parse tsconfig at: ${r}`);if(a.extends){const o=x(a.extends,e),u=J(o);if(delete u.references,(t=u.compilerOptions)!=null&&t.baseUrl){const{compilerOptions:p}=u;p.baseUrl=d.default.relative(e,d.default.join(d.default.dirname(o),p.baseUrl))||"./"}u.files&&(u.files=u.files.map(p=>d.default.relative(e,d.default.join(d.default.dirname(o),p)))),u.include&&(u.include=u.include.map(p=>d.default.relative(e,d.default.join(d.default.dirname(o),p)))),delete a.extends;const c=oe(j(j({},u),a),{compilerOptions:j(j({},u.compilerOptions),a.compilerOptions)});u.watchOptions&&(c.watchOptions=j(j({},u.watchOptions),a.watchOptions)),a=c}if(a.compilerOptions){const{compilerOptions:o}=a;o.baseUrl&&(o.baseUrl=M(o.baseUrl)),o.outDir&&(Array.isArray(a.exclude)||(a.exclude=[]),a.exclude.push(o.outDir),o.outDir=M(o.outDir))}if(a.files&&(a.files=a.files.map(M)),a.include&&(a.include=a.include.map(T)),a.watchOptions){const{watchOptions:o}=a;o.excludeDirectories&&(o.excludeDirectories=o.excludeDirectories.map(u=>T(d.default.resolve(e,u))))}return a}function ie(r=process.cwd(),t="tsconfig.json"){const n=F(r,t);if(!n)return null;const e=J(n);return{path:n,config:e}}const se=/\*/g,H=(r,t)=>{const n=r.match(se);if(n&&n.length>1)throw new Error(t)};function fe(r){if(r.includes("*")){const[t,n]=r.split("*");return{prefix:t,suffix:n}}return r}const ue=({prefix:r,suffix:t},n)=>n.startsWith(r)&&n.endsWith(t);function ce(r,t,n){return Object.entries(r).map(([e,s])=>(H(e,`Pattern '${e}' can have at most one '*' character.`),{pattern:fe(e),substitutions:s.map(a=>{if(H(a,`Substitution '${a}' in pattern '${e}' can have at most one '*' character.`),!t&&!W.test(a))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return d.default.join(n,a)})}))}function le(r){if(!r.config.compilerOptions)return null;const{baseUrl:t,paths:n}=r.config.compilerOptions;if(!t&&!n)return null;const e=d.default.resolve(d.default.dirname(r.path),t||"."),s=n?ce(n,t,e):[];return function(o){if(W.test(o))return[];const u=[];for(const f of s){if(f.pattern===o)return f.substitutions.map(T);typeof f.pattern!="string"&&u.push(f)}let c,p=-1;for(const f of u)ue(f.pattern,o)&&f.pattern.prefix.length>p&&(p=f.pattern.prefix.length,c=f);if(!c)return t?[T(d.default.join(e,o))]:[];const C=o.slice(c.pattern.prefix.length,o.length-c.pattern.suffix.length);return c.substitutions.map(f=>T(f.replace("*",C)))}}exports.createPathsMatcher=le,exports.getTsconfig=ie,exports.parseTsconfig=J;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var G=require("path"),K=require("fs"),Q=require("module");function B(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var d=B(G),O=B(K),X=B(Q);function T(r){const t=/^\\\\\?\\/.test(r),n=/[^\u0000-\u0080]+/.test(r);return t||n?r:r.replace(/\\/g,"/")}function M(r,t){for(;;){const n=d.default.join(r,t);if(O.default.existsSync(n))return T(n);const e=d.default.dirname(r);if(e===r)return;r=e}}function Y(r,t){t===void 0&&(t=!1);var n=r.length,e=0,i="",a=0,o=16,c=0,f=0,p=0,C=0,u=0;function A(s,b){for(var v=0,k=0;v<s||!b;){var h=r.charCodeAt(e);if(h>=48&&h<=57)k=k*16+h-48;else if(h>=65&&h<=70)k=k*16+h-65+10;else if(h>=97&&h<=102)k=k*16+h-97+10;else break;e++,v++}return v<s&&(k=-1),k}function V(s){e=s,i="",a=0,o=16,u=0}function $(){var s=e;if(r.charCodeAt(e)===48)e++;else for(e++;e<r.length&&j(r.charCodeAt(e));)e++;if(e<r.length&&r.charCodeAt(e)===46)if(e++,e<r.length&&j(r.charCodeAt(e)))for(e++;e<r.length&&j(r.charCodeAt(e));)e++;else return u=3,r.substring(s,e);var b=e;if(e<r.length&&(r.charCodeAt(e)===69||r.charCodeAt(e)===101))if(e++,(e<r.length&&r.charCodeAt(e)===43||r.charCodeAt(e)===45)&&e++,e<r.length&&j(r.charCodeAt(e))){for(e++;e<r.length&&j(r.charCodeAt(e));)e++;b=e}else u=3;return r.substring(s,b)}function _(){for(var s="",b=e;;){if(e>=n){s+=r.substring(b,e),u=2;break}var v=r.charCodeAt(e);if(v===34){s+=r.substring(b,e),e++;break}if(v===92){if(s+=r.substring(b,e),e++,e>=n){u=2;break}var k=r.charCodeAt(e++);switch(k){case 34:s+='"';break;case 92:s+="\\";break;case 47:s+="/";break;case 98:s+="\b";break;case 102:s+="\f";break;case 110:s+=`
`;break;case 114:s+="\r";break;case 116:s+=" ";break;case 117:var h=A(4,!0);h>=0?s+=String.fromCharCode(h):u=4;break;default:u=5}b=e;continue}if(v>=0&&v<=31)if(S(v)){s+=r.substring(b,e),u=2;break}else u=6;e++}return s}function P(){if(i="",u=0,a=e,f=c,C=p,e>=n)return a=n,o=17;var s=r.charCodeAt(e);if(U(s)){do e++,i+=String.fromCharCode(s),s=r.charCodeAt(e);while(U(s));return o=15}if(S(s))return e++,i+=String.fromCharCode(s),s===13&&r.charCodeAt(e)===10&&(e++,i+=`
`),c++,p=e,o=14;switch(s){case 123:return e++,o=1;case 125:return e++,o=2;case 91:return e++,o=3;case 93:return e++,o=4;case 58:return e++,o=6;case 44:return e++,o=5;case 34:return e++,i=_(),o=10;case 47:var b=e-1;if(r.charCodeAt(e+1)===47){for(e+=2;e<n&&!S(r.charCodeAt(e));)e++;return i=r.substring(b,e),o=12}if(r.charCodeAt(e+1)===42){e+=2;for(var v=n-1,k=!1;e<v;){var h=r.charCodeAt(e);if(h===42&&r.charCodeAt(e+1)===47){e+=2,k=!0;break}e++,S(h)&&(h===13&&r.charCodeAt(e)===10&&e++,c++,p=e)}return k||(e++,u=1),i=r.substring(b,e),o=13}return i+=String.fromCharCode(s),e++,o=16;case 45:if(i+=String.fromCharCode(s),e++,e===n||!j(r.charCodeAt(e)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=$(),o=11;default:for(;e<n&&m(s);)e++,s=r.charCodeAt(e);if(a!==e){switch(i=r.substring(a,e),i){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return i+=String.fromCharCode(s),e++,o=16}}function m(s){if(U(s)||S(s))return!1;switch(s){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function l(){var s;do s=P();while(s>=12&&s<=15);return s}return{setPosition:V,getPosition:function(){return e},scan:t?l:P,getToken:function(){return o},getTokenValue:function(){return i},getTokenOffset:function(){return a},getTokenLength:function(){return e-a},getTokenStartLine:function(){return f},getTokenStartCharacter:function(){return a-C},getTokenError:function(){return u}}}function U(r){return r===32||r===9||r===11||r===12||r===160||r===5760||r>=8192&&r<=8203||r===8239||r===8287||r===12288||r===65279}function S(r){return r===10||r===13||r===8232||r===8233}function j(r){return r>=48&&r<=57}var N;(function(r){r.DEFAULT={allowTrailingComma:!1}})(N||(N={}));function Z(r,t,n){t===void 0&&(t=[]),n===void 0&&(n=N.DEFAULT);var e=null,i=[],a=[];function o(f){Array.isArray(i)?i.push(f):e!==null&&(i[e]=f)}var c={onObjectBegin:function(){var f={};o(f),a.push(i),i=f,e=null},onObjectProperty:function(f){e=f},onObjectEnd:function(){i=a.pop()},onArrayBegin:function(){var f=[];o(f),a.push(i),i=f,e=null},onArrayEnd:function(){i=a.pop()},onLiteralValue:o,onError:function(f,p,C){t.push({error:f,offset:p,length:C})}};return x(r,c,n),i[0]}function x(r,t,n){n===void 0&&(n=N.DEFAULT);var e=Y(r,!1);function i(g){return g?function(){return g(e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return!0}}function a(g){return g?function(w){return g(w,e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return!0}}var o=i(t.onObjectBegin),c=a(t.onObjectProperty),f=i(t.onObjectEnd),p=i(t.onArrayBegin),C=i(t.onArrayEnd),u=a(t.onLiteralValue),A=a(t.onSeparator),V=i(t.onComment),$=a(t.onError),_=n&&n.disallowComments,P=n&&n.allowTrailingComma;function m(){for(;;){var g=e.scan();switch(e.getTokenError()){case 4:l(14);break;case 5:l(15);break;case 3:l(13);break;case 1:_||l(11);break;case 2:l(12);break;case 6:l(16);break}switch(g){case 12:case 13:_?l(10):V();break;case 16:l(1);break;case 15:case 14:break;default:return g}}}function l(g,w,L){if(w===void 0&&(w=[]),L===void 0&&(L=[]),$(g),w.length+L.length>0)for(var D=e.getToken();D!==17;){if(w.indexOf(D)!==-1){m();break}else if(L.indexOf(D)!==-1)break;D=m()}}function s(g){var w=e.getTokenValue();return g?u(w):c(w),m(),!0}function b(){switch(e.getToken()){case 11:var g=e.getTokenValue(),w=Number(g);isNaN(w)&&(l(2),w=0),u(w);break;case 7:u(null);break;case 8:u(!0);break;case 9:u(!1);break;default:return!1}return m(),!0}function v(){return e.getToken()!==10?(l(3,[],[2,5]),!1):(s(!1),e.getToken()===6?(A(":"),m(),F()||l(4,[],[2,5])):l(5,[],[2,5]),!0)}function k(){o(),m();for(var g=!1;e.getToken()!==2&&e.getToken()!==17;){if(e.getToken()===5){if(g||l(4,[],[]),A(","),m(),e.getToken()===2&&P)break}else g&&l(6,[],[]);v()||l(4,[],[2,5]),g=!0}return f(),e.getToken()!==2?l(7,[2],[]):m(),!0}function h(){p(),m();for(var g=!1;e.getToken()!==4&&e.getToken()!==17;){if(e.getToken()===5){if(g||l(4,[],[]),A(","),m(),e.getToken()===4&&P)break}else g&&l(6,[],[]);F()||l(4,[],[4,5]),g=!0}return C(),e.getToken()!==4?l(8,[4],[]):m(),!0}function F(){switch(e.getToken()){case 3:return h();case 1:return k();case 10:return s(!0);default:return b()}}return m(),e.getToken()===17?n.allowEmptyContent?!0:(l(4,[],[]),!1):F()?(e.getToken()!==17&&l(9,[],[]),!0):(l(4,[],[]),!1)}var ee=Z;const W=/^\.{1,2}(\/.*)?$/,J=r=>T(W.test(r)?r:`./${r}`),{existsSync:E}=O.default,re=r=>{try{return JSON.parse(r)}catch{}},ne=()=>{const{findPnpApi:r}=X.default;return r&&r(process.cwd())};function I(r){const t=re(O.default.readFileSync(r,"utf8"));return d.default.join(r,"..",t&&"tsconfig"in t?t.tsconfig:"tsconfig.json")}function te(r,t){let n=r;if(n===".."&&(n+="/tsconfig.json"),n.startsWith(".")){let a=d.default.resolve(t,n);if(E(a)&&O.default.statSync(a).isFile()||!a.endsWith(".json")&&(a+=".json",E(a)))return a;throw new Error(`File '${r}' not found.`)}const e=ne();if(e){const{resolveRequest:a}=e,[o,c]=r.split("/"),f=o.startsWith("@")?`${o}/${c}`:o;try{if(f===r){const p=a(d.default.join(f,"package.json"),t);if(p){const C=I(p);if(E(C))return C}}else try{return a(r,t,{extensions:[".json"]})}catch{return a(d.default.join(r,"tsconfig.json"),t)}}catch{}}let i=M(t,d.default.join("node_modules",n));if(i){if(O.default.statSync(i).isDirectory()){const a=d.default.join(i,"package.json");if(E(a)?i=I(a):i=d.default.join(i,"tsconfig.json"),E(i))return i}else if(i.endsWith(".json"))return i}if(!n.endsWith(".json")&&(n+=".json",i=M(t,d.default.join("node_modules",n)),i))return i;throw new Error(`File '${r}' not found.`)}var ae=Object.defineProperty,oe=Object.defineProperties,ie=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,z=(r,t,n)=>t in r?ae(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,y=(r,t)=>{for(var n in t||(t={}))se.call(t,n)&&z(r,n,t[n]);if(R)for(var n of R(t))ue.call(t,n)&&z(r,n,t[n]);return r},fe=(r,t)=>oe(r,ie(t));function q(r){var t;let n;try{n=O.default.realpathSync(r)}catch{throw new Error(`Cannot resolve tsconfig at path: ${r}`)}const e=d.default.dirname(n),i=O.default.readFileSync(n,"utf8").trim();let a={};if(i&&(a=ee(i),!a||typeof a!="object"))throw new SyntaxError(`Failed to parse tsconfig at: ${r}`);if(a.extends){const o=te(a.extends,e),c=q(o);if(delete c.references,(t=c.compilerOptions)!=null&&t.baseUrl){const{compilerOptions:p}=c;p.baseUrl=d.default.relative(e,d.default.join(d.default.dirname(o),p.baseUrl))||"./"}c.files&&(c.files=c.files.map(p=>d.default.relative(e,d.default.join(d.default.dirname(o),p)))),c.include&&(c.include=c.include.map(p=>d.default.relative(e,d.default.join(d.default.dirname(o),p)))),delete a.extends;const f=fe(y(y({},c),a),{compilerOptions:y(y({},c.compilerOptions),a.compilerOptions)});c.watchOptions&&(f.watchOptions=y(y({},c.watchOptions),a.watchOptions)),a=f}if(a.compilerOptions){const{compilerOptions:o}=a;o.baseUrl&&(o.baseUrl=J(o.baseUrl)),o.outDir&&(Array.isArray(a.exclude)||(a.exclude=[]),a.exclude.push(o.outDir),o.outDir=J(o.outDir))}if(a.files&&(a.files=a.files.map(J)),a.include&&(a.include=a.include.map(T)),a.watchOptions){const{watchOptions:o}=a;o.excludeDirectories&&(o.excludeDirectories=o.excludeDirectories.map(c=>T(d.default.resolve(e,c))))}return a}function ce(r=process.cwd(),t="tsconfig.json"){const n=M(r,t);if(!n)return null;const e=q(n);return{path:n,config:e}}const le=/\*/g,H=(r,t)=>{const n=r.match(le);if(n&&n.length>1)throw new Error(t)};function de(r){if(r.includes("*")){const[t,n]=r.split("*");return{prefix:t,suffix:n}}return r}const ge=({prefix:r,suffix:t},n)=>n.startsWith(r)&&n.endsWith(t);function pe(r,t,n){return Object.entries(r).map(([e,i])=>(H(e,`Pattern '${e}' can have at most one '*' character.`),{pattern:de(e),substitutions:i.map(a=>{if(H(a,`Substitution '${a}' in pattern '${e}' can have at most one '*' character.`),!t&&!W.test(a))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return d.default.join(n,a)})}))}function he(r){if(!r.config.compilerOptions)return null;const{baseUrl:t,paths:n}=r.config.compilerOptions;if(!t&&!n)return null;const e=d.default.resolve(d.default.dirname(r.path),t||"."),i=n?pe(n,t,e):[];return function(o){if(W.test(o))return[];const c=[];for(const u of i){if(u.pattern===o)return u.substitutions.map(T);typeof u.pattern!="string"&&c.push(u)}let f,p=-1;for(const u of c)ge(u.pattern,o)&&u.pattern.prefix.length>p&&(p=u.pattern.prefix.length,f=u);if(!f)return t?[T(d.default.join(e,o))]:[];const C=o.slice(f.pattern.prefix.length,o.length-f.pattern.suffix.length);return f.substitutions.map(u=>T(u.replace("*",C)))}}exports.createPathsMatcher=he,exports.getTsconfig=ce,exports.parseTsconfig=q;
{
"name": "get-tsconfig",
"version": "4.1.0",
"description": "Find and parse the tsconfig.json file from a directory path",
"keywords": [
"get-tsconfig",
"get",
"typescript",
"tsconfig",
"tsconfig.json"
],
"license": "MIT",
"repository": "privatenumber/get-tsconfig",
"funding": "https://github.com/privatenumber/get-tsconfig?sponsor=1",
"author": {
"name": "Hiroki Osame",
"email": "hiroki.osame@gmail.com"
},
"files": [
"dist"
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"imports": {
"#get-tsconfig": {
"development": "./src/index.ts",
"default": "./dist/index.mjs"
}
},
"scripts": {
"lint": "eslint .",
"build": "pkgroll --minify --target node12.20",
"pretest": "npm run build",
"test": "tsx tests",
"dev": "tsx watch --conditions=development tests"
},
"devDependencies": {
"@pvtnbr/eslint-config": "^0.22.0",
"@types/node": "^17.0.41",
"eslint": "^8.17.0",
"execa": "^6.1.0",
"jsonc-parser": "^3.0.0",
"manten": "^0.1.0",
"pkgroll": "^1.3.1",
"slash": "^4.0.0",
"tsx": "^3.6.0",
"type-fest": "^2.13.1",
"typescript": "^4.7.3"
},
"eslintConfig": {
"extends": "@pvtnbr/eslint-config",
"ignorePatterns": [
"tests/fixtures"
],
"overrides": [
{
"files": "tests/**/*.ts",
"rules": {
"@typescript-eslint/no-shadow": [
"error",
{
"allow": [
"test",
"describe"
]
}
]
}
}
]
}
}
"name": "get-tsconfig",
"version": "4.2.0",
"description": "Find and parse the tsconfig.json file from a directory path",
"keywords": [
"get-tsconfig",
"get",
"typescript",
"tsconfig",
"tsconfig.json"
],
"license": "MIT",
"repository": "privatenumber/get-tsconfig",
"funding": "https://github.com/privatenumber/get-tsconfig?sponsor=1",
"author": {
"name": "Hiroki Osame",
"email": "hiroki.osame@gmail.com"
},
"files": [
"dist"
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"imports": {
"#get-tsconfig": {
"types": "./src/index.ts",
"development": "./src/index.ts",
"default": "./dist/index.mjs"
}
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc