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.0.0 to 4.0.1

6

dist/index.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var z=require("path"),H=require("fs"),ce=require("module");function B(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var g=B(z),V=B(H);function E(r){const a=/^\\\\\?\\/.test(r),n=/[^\u0000-\u0080]+/.test(r);return a||n?r:r.replace(/\\/g,"/")}function J(r,a){for(;;){const n=g.default.join(r,a);if(V.default.existsSync(n))return E(n);const e=g.default.dirname(r);if(e===r)return;r=e}}var q=require;function G(r,a){a===void 0&&(a=!1);var n=r.length,e=0,i="",f=0,t=16,c=0,s=0,k=0,p=0,u=0;function y(o,b){for(var C=0,m=0;C<o||!b;){var h=r.charCodeAt(e);if(h>=48&&h<=57)m=m*16+h-48;else if(h>=65&&h<=70)m=m*16+h-65+10;else if(h>=97&&h<=102)m=m*16+h-97+10;else break;e++,C++}return C<o&&(m=-1),m}function N(o){e=o,i="",f=0,t=16,u=0}function D(){var o=e;if(r.charCodeAt(e)===48)e++;else for(e++;e<r.length&&O(r.charCodeAt(e));)e++;if(e<r.length&&r.charCodeAt(e)===46)if(e++,e<r.length&&O(r.charCodeAt(e)))for(e++;e<r.length&&O(r.charCodeAt(e));)e++;else return u=3,r.substring(o,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&&O(r.charCodeAt(e))){for(e++;e<r.length&&O(r.charCodeAt(e));)e++;b=e}else u=3;return r.substring(o,b)}function S(){for(var o="",b=e;;){if(e>=n){o+=r.substring(b,e),u=2;break}var C=r.charCodeAt(e);if(C===34){o+=r.substring(b,e),e++;break}if(C===92){if(o+=r.substring(b,e),e++,e>=n){u=2;break}var m=r.charCodeAt(e++);switch(m){case 34:o+='"';break;case 92:o+="\\";break;case 47:o+="/";break;case 98:o+="\b";break;case 102:o+="\f";break;case 110:o+=`
`;break;case 114:o+="\r";break;case 116:o+=" ";break;case 117:var h=y(4,!0);h>=0?o+=String.fromCharCode(h):u=4;break;default:u=5}b=e;continue}if(C>=0&&C<=31)if(P(C)){o+=r.substring(b,e),u=2;break}else u=6;e++}return o}function A(){if(i="",u=0,f=e,s=c,p=k,e>=n)return f=n,t=17;var o=r.charCodeAt(e);if($(o)){do e++,i+=String.fromCharCode(o),o=r.charCodeAt(e);while($(o));return t=15}if(P(o))return e++,i+=String.fromCharCode(o),o===13&&r.charCodeAt(e)===10&&(e++,i+=`
`),c++,k=e,t=14;switch(o){case 123:return e++,t=1;case 125:return e++,t=2;case 91:return e++,t=3;case 93:return e++,t=4;case 58:return e++,t=6;case 44:return e++,t=5;case 34:return e++,i=S(),t=10;case 47:var b=e-1;if(r.charCodeAt(e+1)===47){for(e+=2;e<n&&!P(r.charCodeAt(e));)e++;return i=r.substring(b,e),t=12}if(r.charCodeAt(e+1)===42){e+=2;for(var C=n-1,m=!1;e<C;){var h=r.charCodeAt(e);if(h===42&&r.charCodeAt(e+1)===47){e+=2,m=!0;break}e++,P(h)&&(h===13&&r.charCodeAt(e)===10&&e++,c++,k=e)}return m||(e++,u=1),i=r.substring(b,e),t=13}return i+=String.fromCharCode(o),e++,t=16;case 45:if(i+=String.fromCharCode(o),e++,e===n||!O(r.charCodeAt(e)))return t=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=D(),t=11;default:for(;e<n&&v(o);)e++,o=r.charCodeAt(e);if(f!==e){switch(i=r.substring(f,e),i){case"true":return t=8;case"false":return t=9;case"null":return t=7}return t=16}return i+=String.fromCharCode(o),e++,t=16}}function v(o){if($(o)||P(o))return!1;switch(o){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function l(){var o;do o=A();while(o>=12&&o<=15);return o}return{setPosition:N,getPosition:function(){return e},scan:a?l:A,getToken:function(){return t},getTokenValue:function(){return i},getTokenOffset:function(){return f},getTokenLength:function(){return e-f},getTokenStartLine:function(){return s},getTokenStartCharacter:function(){return f-p},getTokenError:function(){return u}}}function $(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 P(r){return r===10||r===13||r===8232||r===8233}function O(r){return r>=48&&r<=57}var L;(function(r){r.DEFAULT={allowTrailingComma:!1}})(L||(L={}));function K(r,a,n){a===void 0&&(a=[]),n===void 0&&(n=L.DEFAULT);var e=null,i=[],f=[];function t(s){Array.isArray(i)?i.push(s):e!==null&&(i[e]=s)}var c={onObjectBegin:function(){var s={};t(s),f.push(i),i=s,e=null},onObjectProperty:function(s){e=s},onObjectEnd:function(){i=f.pop()},onArrayBegin:function(){var s=[];t(s),f.push(i),i=s,e=null},onArrayEnd:function(){i=f.pop()},onLiteralValue:t,onError:function(s,k,p){a.push({error:s,offset:k,length:p})}};return Q(r,c,n),i[0]}function Q(r,a,n){n===void 0&&(n=L.DEFAULT);var e=G(r,!1);function i(d){return d?function(){return d(e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return!0}}function f(d){return d?function(w){return d(w,e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return!0}}var t=i(a.onObjectBegin),c=f(a.onObjectProperty),s=i(a.onObjectEnd),k=i(a.onArrayBegin),p=i(a.onArrayEnd),u=f(a.onLiteralValue),y=f(a.onSeparator),N=i(a.onComment),D=f(a.onError),S=n&&n.disallowComments,A=n&&n.allowTrailingComma;function v(){for(;;){var d=e.scan();switch(e.getTokenError()){case 4:l(14);break;case 5:l(15);break;case 3:l(13);break;case 1:S||l(11);break;case 2:l(12);break;case 6:l(16);break}switch(d){case 12:case 13:S?l(10):N();break;case 16:l(1);break;case 15:case 14:break;default:return d}}}function l(d,w,_){if(w===void 0&&(w=[]),_===void 0&&(_=[]),D(d),w.length+_.length>0)for(var j=e.getToken();j!==17;){if(w.indexOf(j)!==-1){v();break}else if(_.indexOf(j)!==-1)break;j=v()}}function o(d){var w=e.getTokenValue();return d?u(w):c(w),v(),!0}function b(){switch(e.getToken()){case 11:var d=e.getTokenValue(),w=Number(d);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 v(),!0}function C(){return e.getToken()!==10?(l(3,[],[2,5]),!1):(o(!1),e.getToken()===6?(y(":"),v(),U()||l(4,[],[2,5])):l(5,[],[2,5]),!0)}function m(){t(),v();for(var d=!1;e.getToken()!==2&&e.getToken()!==17;){if(e.getToken()===5){if(d||l(4,[],[]),y(","),v(),e.getToken()===2&&A)break}else d&&l(6,[],[]);C()||l(4,[],[2,5]),d=!0}return s(),e.getToken()!==2?l(7,[2],[]):v(),!0}function h(){k(),v();for(var d=!1;e.getToken()!==4&&e.getToken()!==17;){if(e.getToken()===5){if(d||l(4,[],[]),y(","),v(),e.getToken()===4&&A)break}else d&&l(6,[],[]);U()||l(4,[],[4,5]),d=!0}return p(),e.getToken()!==4?l(8,[4],[]):v(),!0}function U(){switch(e.getToken()){case 3:return h();case 1:return m();case 10:return o(!0);default:return b()}}return v(),e.getToken()===17?n.allowEmptyContent?!0:(l(4,[],[]),!1):U()?(e.getToken()!==17&&l(9,[],[]),!0):(l(4,[],[]),!1)}var X=K;const M=r=>E(/^[./]/.test(r)?r:`./${r}`);var Y=Object.defineProperty,Z=Object.defineProperties,x=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,ee=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,R=(r,a,n)=>a in r?Y(r,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[a]=n,T=(r,a)=>{for(var n in a||(a={}))ee.call(a,n)&&R(r,n,a[n]);if(F)for(var n of F(a))re.call(a,n)&&R(r,n,a[n]);return r},ne=(r,a)=>Z(r,x(a));function W(r){var a,n;const e=V.default.realpathSync(r),i=g.default.dirname(e),f=V.default.readFileSync(r,"utf8").trim();let t={};if(f&&(t=X(f),!t||typeof t!="object"))throw new SyntaxError(`Failed to parse JSON: ${r}`);if(t.extends){let c=t.extends;try{c=q.resolve(c,{paths:[g.default.dirname(r)]})}catch(p){if(p.code==="MODULE_NOT_FOUND")try{c=q.resolve(g.default.join(c,"tsconfig.json"),{paths:[g.default.dirname(r)]})}catch{}}const s=W(c);if(delete s.references,(a=s.compilerOptions)!=null&&a.baseUrl){const{compilerOptions:p}=s;p.baseUrl=g.default.relative(i,g.default.join(g.default.dirname(c),p.baseUrl))}s.files&&(s.files=s.files.map(p=>g.default.relative(i,g.default.join(g.default.dirname(c),p)))),s.include&&(s.include=s.include.map(p=>g.default.relative(i,g.default.join(g.default.dirname(c),p)))),delete t.extends;const k=ne(T(T({},s),t),{compilerOptions:T(T({},s.compilerOptions),t.compilerOptions)});s.watchOptions&&(k.watchOptions=T(T({},s.watchOptions),t.watchOptions)),t=k}if((n=t.compilerOptions)!=null&&n.baseUrl){const{compilerOptions:c}=t;c.baseUrl=M(c.baseUrl)}if(t.files&&(t.files=t.files.map(M)),t.include&&(t.include=t.include.map(E)),t.watchOptions){const{watchOptions:c}=t;c.excludeDirectories&&(c.excludeDirectories=c.excludeDirectories.map(s=>E(g.default.resolve(i,s))))}return t}function te(r=process.cwd(),a="tsconfig.json"){const n=J(r,a);if(!n)return null;const e=W(n);return{path:n,config:e}}const ae=/^\.{1,2}\//,oe=/\*/g,I=(r,a)=>{const n=r.match(oe);if(n&&n.length>1)throw new Error(a)};function ie(r){if(r.includes("*")){const[a,n]=r.split("*");return{prefix:a,suffix:n}}return r}const se=({prefix:r,suffix:a},n)=>n.startsWith(r)&&n.endsWith(a);function ue(r,a,n){return Object.entries(r).map(([e,i])=>(I(e,`Pattern '${e}' can have at most one '*' character.`),{pattern:ie(e),substitutions:i.map(f=>{if(I(f,`Substitution '${f}' in pattern '${e}' can have at most one '*' character.`),!f.startsWith("./")&&!a)throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return g.default.join(n,f)})}))}function fe(r){if(!r.config.compilerOptions)return null;const{baseUrl:a,paths:n}=r.config.compilerOptions;if(!a&&!n)return null;const e=g.default.resolve(g.default.dirname(r.path),a||"."),i=n?ue(n,a,e):[];return function(t){if(ae.test(t))return[];const c=[];for(const u of i){if(u.pattern===t)return u.substitutions;typeof u.pattern!="string"&&c.push(u)}let s,k=-1;for(const u of c)se(u.pattern,t)&&u.pattern.prefix.length>k&&(k=u.pattern.prefix.length,s=u);if(!s)return a?[g.default.join(e,t)]:[];const p=t.slice(s.pattern.prefix.length,t.length-s.pattern.suffix.length);return s.substitutions.map(u=>u.replace("*",p))}}exports.createPathsMatcher=fe,exports.getTsconfig=te;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var z=require("path"),H=require("fs");function $(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var l=$(z),O=$(H);function L(r){const a=/^\\\\\?\\/.test(r),n=/[^\u0000-\u0080]+/.test(r);return a||n?r:r.replace(/\\/g,"/")}function M(r,a){for(;;){const n=l.default.join(r,a);if(O.default.existsSync(n))return L(n);const e=l.default.dirname(r);if(e===r)return;r=e}}function G(r,a){a===void 0&&(a=!1);var n=r.length,e=0,i="",u=0,t=16,d=0,s=0,m=0,h=0,f=0;function j(o,b){for(var C=0,k=0;C<o||!b;){var p=r.charCodeAt(e);if(p>=48&&p<=57)k=k*16+p-48;else if(p>=65&&p<=70)k=k*16+p-65+10;else if(p>=97&&p<=102)k=k*16+p-97+10;else break;e++,C++}return C<o&&(k=-1),k}function V(o){e=o,i="",u=0,t=16,f=0}function B(){var o=e;if(r.charCodeAt(e)===48)e++;else for(e++;e<r.length&&T(r.charCodeAt(e));)e++;if(e<r.length&&r.charCodeAt(e)===46)if(e++,e<r.length&&T(r.charCodeAt(e)))for(e++;e<r.length&&T(r.charCodeAt(e));)e++;else return f=3,r.substring(o,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&&T(r.charCodeAt(e))){for(e++;e<r.length&&T(r.charCodeAt(e));)e++;b=e}else f=3;return r.substring(o,b)}function P(){for(var o="",b=e;;){if(e>=n){o+=r.substring(b,e),f=2;break}var C=r.charCodeAt(e);if(C===34){o+=r.substring(b,e),e++;break}if(C===92){if(o+=r.substring(b,e),e++,e>=n){f=2;break}var k=r.charCodeAt(e++);switch(k){case 34:o+='"';break;case 92:o+="\\";break;case 47:o+="/";break;case 98:o+="\b";break;case 102:o+="\f";break;case 110:o+=`
`;break;case 114:o+="\r";break;case 116:o+=" ";break;case 117:var p=j(4,!0);p>=0?o+=String.fromCharCode(p):f=4;break;default:f=5}b=e;continue}if(C>=0&&C<=31)if(S(C)){o+=r.substring(b,e),f=2;break}else f=6;e++}return o}function A(){if(i="",f=0,u=e,s=d,h=m,e>=n)return u=n,t=17;var o=r.charCodeAt(e);if(F(o)){do e++,i+=String.fromCharCode(o),o=r.charCodeAt(e);while(F(o));return t=15}if(S(o))return e++,i+=String.fromCharCode(o),o===13&&r.charCodeAt(e)===10&&(e++,i+=`
`),d++,m=e,t=14;switch(o){case 123:return e++,t=1;case 125:return e++,t=2;case 91:return e++,t=3;case 93:return e++,t=4;case 58:return e++,t=6;case 44:return e++,t=5;case 34:return e++,i=P(),t=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),t=12}if(r.charCodeAt(e+1)===42){e+=2;for(var C=n-1,k=!1;e<C;){var p=r.charCodeAt(e);if(p===42&&r.charCodeAt(e+1)===47){e+=2,k=!0;break}e++,S(p)&&(p===13&&r.charCodeAt(e)===10&&e++,d++,m=e)}return k||(e++,f=1),i=r.substring(b,e),t=13}return i+=String.fromCharCode(o),e++,t=16;case 45:if(i+=String.fromCharCode(o),e++,e===n||!T(r.charCodeAt(e)))return t=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=B(),t=11;default:for(;e<n&&v(o);)e++,o=r.charCodeAt(e);if(u!==e){switch(i=r.substring(u,e),i){case"true":return t=8;case"false":return t=9;case"null":return t=7}return t=16}return i+=String.fromCharCode(o),e++,t=16}}function v(o){if(F(o)||S(o))return!1;switch(o){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function c(){var o;do o=A();while(o>=12&&o<=15);return o}return{setPosition:V,getPosition:function(){return e},scan:a?c:A,getToken:function(){return t},getTokenValue:function(){return i},getTokenOffset:function(){return u},getTokenLength:function(){return e-u},getTokenStartLine:function(){return s},getTokenStartCharacter:function(){return u-h},getTokenError:function(){return f}}}function F(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 T(r){return r>=48&&r<=57}var N;(function(r){r.DEFAULT={allowTrailingComma:!1}})(N||(N={}));function K(r,a,n){a===void 0&&(a=[]),n===void 0&&(n=N.DEFAULT);var e=null,i=[],u=[];function t(s){Array.isArray(i)?i.push(s):e!==null&&(i[e]=s)}var d={onObjectBegin:function(){var s={};t(s),u.push(i),i=s,e=null},onObjectProperty:function(s){e=s},onObjectEnd:function(){i=u.pop()},onArrayBegin:function(){var s=[];t(s),u.push(i),i=s,e=null},onArrayEnd:function(){i=u.pop()},onLiteralValue:t,onError:function(s,m,h){a.push({error:s,offset:m,length:h})}};return Q(r,d,n),i[0]}function Q(r,a,n){n===void 0&&(n=N.DEFAULT);var e=G(r,!1);function i(g){return g?function(){return g(e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return!0}}function u(g){return g?function(w){return g(w,e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter())}:function(){return!0}}var t=i(a.onObjectBegin),d=u(a.onObjectProperty),s=i(a.onObjectEnd),m=i(a.onArrayBegin),h=i(a.onArrayEnd),f=u(a.onLiteralValue),j=u(a.onSeparator),V=i(a.onComment),B=u(a.onError),P=n&&n.disallowComments,A=n&&n.allowTrailingComma;function v(){for(;;){var g=e.scan();switch(e.getTokenError()){case 4:c(14);break;case 5:c(15);break;case 3:c(13);break;case 1:P||c(11);break;case 2:c(12);break;case 6:c(16);break}switch(g){case 12:case 13:P?c(10):V();break;case 16:c(1);break;case 15:case 14:break;default:return g}}}function c(g,w,E){if(w===void 0&&(w=[]),E===void 0&&(E=[]),B(g),w.length+E.length>0)for(var _=e.getToken();_!==17;){if(w.indexOf(_)!==-1){v();break}else if(E.indexOf(_)!==-1)break;_=v()}}function o(g){var w=e.getTokenValue();return g?f(w):d(w),v(),!0}function b(){switch(e.getToken()){case 11:var g=e.getTokenValue(),w=Number(g);isNaN(w)&&(c(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 v(),!0}function C(){return e.getToken()!==10?(c(3,[],[2,5]),!1):(o(!1),e.getToken()===6?(j(":"),v(),U()||c(4,[],[2,5])):c(5,[],[2,5]),!0)}function k(){t(),v();for(var g=!1;e.getToken()!==2&&e.getToken()!==17;){if(e.getToken()===5){if(g||c(4,[],[]),j(","),v(),e.getToken()===2&&A)break}else g&&c(6,[],[]);C()||c(4,[],[2,5]),g=!0}return s(),e.getToken()!==2?c(7,[2],[]):v(),!0}function p(){m(),v();for(var g=!1;e.getToken()!==4&&e.getToken()!==17;){if(e.getToken()===5){if(g||c(4,[],[]),j(","),v(),e.getToken()===4&&A)break}else g&&c(6,[],[]);U()||c(4,[],[4,5]),g=!0}return h(),e.getToken()!==4?c(8,[4],[]):v(),!0}function U(){switch(e.getToken()){case 3:return p();case 1:return k();case 10:return o(!0);default:return b()}}return v(),e.getToken()===17?n.allowEmptyContent?!0:(c(4,[],[]),!1):U()?(e.getToken()!==17&&c(9,[],[]),!0):(c(4,[],[]),!1)}var X=K;const W=r=>L(/^[./]/.test(r)?r:`./${r}`),D=r=>O.default.existsSync(r),Y=r=>{try{return JSON.parse(r)}catch{}};function Z(r,a){if(r===".."&&(r+="/tsconfig.json"),r.startsWith(".")){let n=l.default.resolve(a,r);if(D(n)&&O.default.statSync(n).isFile()||!n.endsWith(".json")&&(n+=".json",D(n)))return n}else{let n=M(a,l.default.join("node_modules",r));if(n)if(O.default.statSync(n).isDirectory()){const e=l.default.join(n,"package.json");if(D(e)){const i=Y(O.default.readFileSync(e,"utf8"));i&&"tsconfig"in i?n=l.default.join(n,i.tsconfig):n=l.default.join(n,"tsconfig.json")}else n=l.default.join(n,"tsconfig.json");if(D(n))return n}else return n}throw new Error(`File '${r}' not found.`)}var x=Object.defineProperty,ee=Object.defineProperties,re=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable,q=(r,a,n)=>a in r?x(r,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[a]=n,y=(r,a)=>{for(var n in a||(a={}))ne.call(a,n)&&q(r,n,a[n]);if(J)for(var n of J(a))te.call(a,n)&&q(r,n,a[n]);return r},ae=(r,a)=>ee(r,re(a));function I(r){var a,n;const e=O.default.realpathSync(r),i=l.default.dirname(e),u=O.default.readFileSync(r,"utf8").trim();let t={};if(u&&(t=X(u),!t||typeof t!="object"))throw new SyntaxError(`Failed to parse JSON: ${r}`);if(t.extends){const d=Z(t.extends,i),s=I(d);if(delete s.references,(a=s.compilerOptions)!=null&&a.baseUrl){const{compilerOptions:h}=s;h.baseUrl=l.default.relative(i,l.default.join(l.default.dirname(d),h.baseUrl))}s.files&&(s.files=s.files.map(h=>l.default.relative(i,l.default.join(l.default.dirname(d),h)))),s.include&&(s.include=s.include.map(h=>l.default.relative(i,l.default.join(l.default.dirname(d),h)))),delete t.extends;const m=ae(y(y({},s),t),{compilerOptions:y(y({},s.compilerOptions),t.compilerOptions)});s.watchOptions&&(m.watchOptions=y(y({},s.watchOptions),t.watchOptions)),t=m}if((n=t.compilerOptions)!=null&&n.baseUrl){const{compilerOptions:d}=t;d.baseUrl=W(d.baseUrl)}if(t.files&&(t.files=t.files.map(W)),t.include&&(t.include=t.include.map(L)),t.watchOptions){const{watchOptions:d}=t;d.excludeDirectories&&(d.excludeDirectories=d.excludeDirectories.map(s=>L(l.default.resolve(i,s))))}return t}function oe(r=process.cwd(),a="tsconfig.json"){const n=M(r,a);if(!n)return null;const e=I(n);return{path:n,config:e}}const ie=/^\.{1,2}\//,se=/\*/g,R=(r,a)=>{const n=r.match(se);if(n&&n.length>1)throw new Error(a)};function fe(r){if(r.includes("*")){const[a,n]=r.split("*");return{prefix:a,suffix:n}}return r}const ue=({prefix:r,suffix:a},n)=>n.startsWith(r)&&n.endsWith(a);function ce(r,a,n){return Object.entries(r).map(([e,i])=>(R(e,`Pattern '${e}' can have at most one '*' character.`),{pattern:fe(e),substitutions:i.map(u=>{if(R(u,`Substitution '${u}' in pattern '${e}' can have at most one '*' character.`),!u.startsWith("./")&&!a)throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return l.default.join(n,u)})}))}function le(r){if(!r.config.compilerOptions)return null;const{baseUrl:a,paths:n}=r.config.compilerOptions;if(!a&&!n)return null;const e=l.default.resolve(l.default.dirname(r.path),a||"."),i=n?ce(n,a,e):[];return function(t){if(ie.test(t))return[];const d=[];for(const f of i){if(f.pattern===t)return f.substitutions;typeof f.pattern!="string"&&d.push(f)}let s,m=-1;for(const f of d)ue(f.pattern,t)&&f.pattern.prefix.length>m&&(m=f.pattern.prefix.length,s=f);if(!s)return a?[l.default.join(e,t)]:[];const h=t.slice(s.pattern.prefix.length,t.length-s.pattern.suffix.length);return s.substitutions.map(f=>f.replace("*",h))}}exports.createPathsMatcher=le,exports.getTsconfig=oe;
{
"name": "get-tsconfig",
"version": "4.0.0",
"version": "4.0.1",
"description": "Find and parse the tsconfig.json file from a directory path",

@@ -5,0 +5,0 @@ "keywords": [

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