@stryke/fs 0.33.0 → 0.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/resolve.cjs CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DEFAULT_EXTENSIONS = void 0;
7
+ exports.getNodeModulesPaths = getNodeModulesPaths;
7
8
  exports.getResolutionCombinations = getResolutionCombinations;
8
9
  exports.getResolutionPaths = getResolutionPaths;
9
10
  exports.importModule = importModule;
@@ -21,117 +22,124 @@ var _filePathFns = require("@stryke/path/file-path-fns");
21
22
  var _isType = require("@stryke/path/is-type");
22
23
  var _joinPaths = require("@stryke/path/join-paths");
23
24
  var _mlly = require("mlly");
25
+ var _exists = require("./exists.cjs");
24
26
  var _getWorkspaceRoot = require("./get-workspace-root.cjs");
25
27
  const DEFAULT_EXTENSIONS = exports.DEFAULT_EXTENSIONS = ["js", "jsx", "mjs", "cjs", "ts", "tsx", "mts", "cts", "json", "jsonc", "json5", "node"];
26
28
  function getResolutionPaths(n = []) {
27
- let e = n;
28
- e.includes((0, _cwd.cwd)()) || e.push((0, _cwd.cwd)());
29
- const t = (0, _getWorkspaceRoot.getWorkspaceRoot)();
30
- return e.includes(t) || e.push(t), e = (0, _getUnique.getUnique)(e.filter(Boolean).map(r => (0, _correctPath.correctPath)(r)).reduce((r, i, s, o) => (r.push(i), (0, _isType.isAbsolutePath)(i) || (r.push((0, _correctPath.toAbsolutePath)(i, (0, _cwd.cwd)())), r.push((0, _correctPath.toAbsolutePath)(i, t)), o.forEach(l => {
31
- r.push((0, _correctPath.toAbsolutePath)(i, l));
32
- })), r), [])), e;
29
+ let r = n;
30
+ r.includes((0, _cwd.cwd)()) || r.push((0, _cwd.cwd)());
31
+ const e = (0, _getWorkspaceRoot.getWorkspaceRoot)();
32
+ return r.includes(e) || r.push(e), r = (0, _getUnique.getUnique)(r.filter(Boolean).map(s => (0, _correctPath.correctPath)(s)).reduce((s, i, t, o) => (s.push(i), (0, _isType.isAbsolutePath)(i) || (s.push((0, _correctPath.toAbsolutePath)(i, (0, _cwd.cwd)())), s.push((0, _correctPath.toAbsolutePath)(i, e)), o.forEach(f => {
33
+ s.push((0, _correctPath.toAbsolutePath)(i, f));
34
+ })), s), [])), r;
33
35
  }
34
- function getResolutionCombinations(n, e = {}) {
35
- const t = getResolutionPaths(e.paths),
36
- r = e.extensions ?? DEFAULT_EXTENSIONS;
37
- let i = t.map(s => (0, _joinPaths.joinPaths)(n, s));
36
+ function getNodeModulesPaths(n = []) {
37
+ return (0, _getUnique.getUnique)(n.reduce((r, e) => ((0, _filePathFns.findFolderName)(e) === "node_modules" && r.push((0, _correctPath.correctPath)(e)), (0, _exists.existsSync)((0, _joinPaths.joinPaths)(e, "node_modules")) && r.push((0, _correctPath.correctPath)((0, _joinPaths.joinPaths)(e, "node_modules"))), r), []));
38
+ }
39
+ function getResolutionCombinations(n, r = {}) {
40
+ let e = getResolutionPaths(r.paths);
41
+ (0, _isType.isNpmScopedPackage)(n) ? e = getNodeModulesPaths(e) : e.push(...getNodeModulesPaths(e));
42
+ const s = r.extensions ?? DEFAULT_EXTENSIONS;
43
+ let i = e.map(t => (0, _joinPaths.joinPaths)(n, t));
38
44
  return (0, _filePathFns.findFileName)(n, {
39
45
  withExtension: !1
40
- }) !== "index" && (i = i.reduce((s, o) => (s.push(o), s.push((0, _joinPaths.joinPaths)(o, "index")), s), [])), (0, _filePathFns.findFileExtension)(n) || (i = i.reduce((s, o) => (s.push(o), r.forEach(l => {
41
- s.push((0, _path.appendExtension)(o, l));
42
- }), s), [])), (0, _getUnique.getUnique)(i.filter(Boolean)).map(s => (0, _correctPath.correctPath)(s));
46
+ }) !== "index" && (i = i.reduce((t, o) => (t.push(o), t.push((0, _joinPaths.joinPaths)(o, "index")), t), [])), (0, _filePathFns.findFileExtension)(n) || (i = i.reduce((t, o) => (t.push(o), s.forEach(f => {
47
+ t.push((0, _path.appendExtension)(o, f));
48
+ }), t), [])), (0, _getUnique.getUnique)(i.filter(Boolean)).map(t => (0, _correctPath.correctPath)(t));
43
49
  }
44
- async function resolve(n, e = {}) {
45
- const t = getResolutionPaths(e.paths);
46
- let r, i;
50
+ async function resolve(n, r = {}) {
51
+ let e = getResolutionPaths(r.paths);
52
+ (0, _isType.isNpmScopedPackage)(n) ? e = getNodeModulesPaths(e) : e.push(...getNodeModulesPaths(e));
53
+ let s, i;
47
54
  try {
48
- r = await (0, _mlly.resolvePath)(n, {
49
- url: t,
50
- extensions: e.extensions ?? DEFAULT_EXTENSIONS,
51
- conditions: e.conditions
55
+ s = await (0, _mlly.resolvePath)(n, {
56
+ url: e,
57
+ extensions: r.extensions ?? DEFAULT_EXTENSIONS,
58
+ conditions: r.conditions
52
59
  });
53
- } catch (s) {
54
- i = s;
60
+ } catch (t) {
61
+ i = t;
55
62
  }
56
- if (!r) for (let s = 0; s < t.length && !r; s++) try {
57
- r = await (0, _mlly.resolvePath)((0, _path.replacePath)(n, t[s]), {
58
- url: t,
59
- extensions: e.extensions ?? DEFAULT_EXTENSIONS,
60
- conditions: e.conditions
63
+ if (!s) for (let t = 0; t < e.length && !s; t++) try {
64
+ s = await (0, _mlly.resolvePath)((0, _path.replacePath)(n, e[t]), {
65
+ url: e,
66
+ extensions: r.extensions ?? DEFAULT_EXTENSIONS,
67
+ conditions: r.conditions
61
68
  });
62
69
  } catch (o) {
63
70
  i = o;
64
71
  }
65
- if (!r && (0, _filePathFns.findFileName)(n, {
72
+ if (!s && (0, _filePathFns.findFileName)(n, {
66
73
  withExtension: !1
67
74
  }) !== "index") try {
68
- r = await resolve((0, _joinPaths.joinPaths)(n, "index"), {
69
- ...e,
70
- paths: t
71
- }), r && (r = (0, _filePathFns.findFilePath)(r));
72
- } catch (s) {
73
- i = s;
75
+ s = await resolve((0, _joinPaths.joinPaths)(n, "index"), {
76
+ ...r,
77
+ paths: e
78
+ }), s && (s = (0, _filePathFns.findFilePath)(s));
79
+ } catch (t) {
80
+ i = t;
74
81
  }
75
- if (!r) throw i ?? new Error(`Cannot resolve module '${n}'`);
76
- return (0, _correctPath.correctPath)(r);
82
+ if (!s) throw i ?? new Error(`Cannot resolve module '${n}'`);
83
+ return (0, _correctPath.correctPath)(s);
77
84
  }
78
- function resolveSync(n, e = {}) {
79
- const t = getResolutionPaths(e.paths);
80
- let r, i;
85
+ function resolveSync(n, r = {}) {
86
+ let e = getResolutionPaths(r.paths);
87
+ (0, _isType.isNpmScopedPackage)(n) ? e = getNodeModulesPaths(e) : e.push(...getNodeModulesPaths(e));
88
+ let s, i;
81
89
  try {
82
- r = (0, _mlly.resolvePathSync)(n, {
83
- url: t,
84
- extensions: e.extensions ?? DEFAULT_EXTENSIONS,
85
- conditions: e.conditions
90
+ s = (0, _mlly.resolvePathSync)(n, {
91
+ url: e,
92
+ extensions: r.extensions ?? DEFAULT_EXTENSIONS,
93
+ conditions: r.conditions
86
94
  });
87
- } catch (s) {
88
- i = s;
95
+ } catch (t) {
96
+ i = t;
89
97
  }
90
- if (!r) for (let s = 0; s < t.length && !r; s++) try {
91
- r = (0, _mlly.resolvePathSync)((0, _path.replacePath)(n, t[s]), {
92
- url: t,
93
- extensions: e.extensions ?? DEFAULT_EXTENSIONS,
94
- conditions: e.conditions
98
+ if (!s) for (let t = 0; t < e.length && !s; t++) try {
99
+ s = (0, _mlly.resolvePathSync)((0, _path.replacePath)(n, e[t]), {
100
+ url: e,
101
+ extensions: r.extensions ?? DEFAULT_EXTENSIONS,
102
+ conditions: r.conditions
95
103
  });
96
104
  } catch (o) {
97
105
  i = o;
98
106
  }
99
- if (!r && (0, _filePathFns.findFileName)(n, {
107
+ if (!s && (0, _filePathFns.findFileName)(n, {
100
108
  withExtension: !1
101
109
  }) !== "index") try {
102
- r = resolveSync((0, _joinPaths.joinPaths)(n, "index"), {
103
- ...e,
104
- paths: t
105
- }), r && (r = (0, _filePathFns.findFilePath)(r));
106
- } catch (s) {
107
- i = s;
110
+ s = resolveSync((0, _joinPaths.joinPaths)(n, "index"), {
111
+ ...r,
112
+ paths: e
113
+ }), s && (s = (0, _filePathFns.findFilePath)(s));
114
+ } catch (t) {
115
+ i = t;
108
116
  }
109
- if (!r) throw i ?? new Error(`Cannot resolve module '${n}'`);
110
- return (0, _correctPath.correctPath)(r);
117
+ if (!s) throw i ?? new Error(`Cannot resolve module '${n}'`);
118
+ return (0, _correctPath.correctPath)(s);
111
119
  }
112
- async function resolveSafe(n, e = {}) {
120
+ async function resolveSafe(n, r = {}) {
113
121
  try {
114
- return await resolve(n, e);
122
+ return await resolve(n, r);
115
123
  } catch {
116
124
  return;
117
125
  }
118
126
  }
119
- function resolveSafeSync(n, e = {}) {
127
+ function resolveSafeSync(n, r = {}) {
120
128
  try {
121
- return resolveSync(n, e);
129
+ return resolveSync(n, r);
122
130
  } catch {
123
131
  return;
124
132
  }
125
133
  }
126
134
  async function importModule(n) {
127
- const e = await Promise.resolve(`${n}`).then(s => require(s));
128
- return e && (0, _mlly.interopDefault)(e);
135
+ const r = await Promise.resolve(`${n}`).then(s => require(s));
136
+ return r && (0, _mlly.interopDefault)(r);
129
137
  }
130
- async function resolvePackage(n, e = {}) {
131
- let t = await resolveSafe((0, _joinPaths.joinPaths)(n, "package.json"), e);
132
- return t || (t = await resolveSafe((0, _joinPaths.joinPaths)(n, "index.js"), e), t || (t = await resolveSafe(n, e))), t ? (0, _filePathFns.findFilePath)(t) : void 0;
138
+ async function resolvePackage(n, r = {}) {
139
+ let e = await resolveSafe((0, _joinPaths.joinPaths)(n, "package.json"), r);
140
+ return e || (e = await resolveSafe((0, _joinPaths.joinPaths)(n, "index.js"), r), e || (e = await resolveSafe(n, r))), e ? (0, _filePathFns.findFilePath)(e) : void 0;
133
141
  }
134
- function resolvePackageSync(n, e = {}) {
135
- let t = resolveSafeSync((0, _joinPaths.joinPaths)(n, "package.json"), e);
136
- return t || (t = resolveSafeSync((0, _joinPaths.joinPaths)(n, "index.js"), e), t || (t = resolveSafeSync(n, e))), t ? (0, _filePathFns.findFilePath)(t) : void 0;
142
+ function resolvePackageSync(n, r = {}) {
143
+ let e = resolveSafeSync((0, _joinPaths.joinPaths)(n, "package.json"), r);
144
+ return e || (e = resolveSafeSync((0, _joinPaths.joinPaths)(n, "index.js"), r), e || (e = resolveSafeSync(n, r))), e ? (0, _filePathFns.findFilePath)(e) : void 0;
137
145
  }
package/dist/resolve.d.ts CHANGED
@@ -25,6 +25,13 @@ export interface ResolveOptions {
25
25
  * @returns An array of unique, corrected resolution paths.
26
26
  */
27
27
  export declare function getResolutionPaths(paths?: string[]): string[];
28
+ /**
29
+ * Get the node_modules resolution paths based on the provided paths.
30
+ *
31
+ * @param paths - An array of paths to include in the resolution.
32
+ * @returns An array of unique, corrected node_modules resolution paths.
33
+ */
34
+ export declare function getNodeModulesPaths(paths?: string[]): any;
28
35
  /**
29
36
  * Get all combinations of resolution paths for a given path and options.
30
37
  *
package/dist/resolve.mjs CHANGED
@@ -1 +1 @@
1
- import{getUnique as h}from"@stryke/helpers/get-unique";import{appendExtension as E,replacePath as p}from"@stryke/path";import{correctPath as a,toAbsolutePath as f}from"@stryke/path/correct-path";import{cwd as d}from"@stryke/path/cwd";import{findFileExtension as v,findFileName as x,findFilePath as u}from"@stryke/path/file-path-fns";import{isAbsolutePath as w}from"@stryke/path/is-type";import{joinPaths as c}from"@stryke/path/join-paths";import{interopDefault as y,resolvePath as g,resolvePathSync as m}from"mlly";import{getWorkspaceRoot as P}from"./get-workspace-root";export const DEFAULT_EXTENSIONS=["js","jsx","mjs","cjs","ts","tsx","mts","cts","json","jsonc","json5","node"];export function getResolutionPaths(n=[]){let e=n;e.includes(d())||e.push(d());const t=P();return e.includes(t)||e.push(t),e=h(e.filter(Boolean).map(r=>a(r)).reduce((r,i,s,o)=>(r.push(i),w(i)||(r.push(f(i,d())),r.push(f(i,t)),o.forEach(l=>{r.push(f(i,l))})),r),[])),e}export function getResolutionCombinations(n,e={}){const t=getResolutionPaths(e.paths),r=e.extensions??DEFAULT_EXTENSIONS;let i=t.map(s=>c(n,s));return x(n,{withExtension:!1})!=="index"&&(i=i.reduce((s,o)=>(s.push(o),s.push(c(o,"index")),s),[])),v(n)||(i=i.reduce((s,o)=>(s.push(o),r.forEach(l=>{s.push(E(o,l))}),s),[])),h(i.filter(Boolean)).map(s=>a(s))}export async function resolve(n,e={}){const t=getResolutionPaths(e.paths);let r,i;try{r=await g(n,{url:t,extensions:e.extensions??DEFAULT_EXTENSIONS,conditions:e.conditions})}catch(s){i=s}if(!r)for(let s=0;s<t.length&&!r;s++)try{r=await g(p(n,t[s]),{url:t,extensions:e.extensions??DEFAULT_EXTENSIONS,conditions:e.conditions})}catch(o){i=o}if(!r&&x(n,{withExtension:!1})!=="index")try{r=await resolve(c(n,"index"),{...e,paths:t}),r&&(r=u(r))}catch(s){i=s}if(!r)throw i??new Error(`Cannot resolve module '${n}'`);return a(r)}export function resolveSync(n,e={}){const t=getResolutionPaths(e.paths);let r,i;try{r=m(n,{url:t,extensions:e.extensions??DEFAULT_EXTENSIONS,conditions:e.conditions})}catch(s){i=s}if(!r)for(let s=0;s<t.length&&!r;s++)try{r=m(p(n,t[s]),{url:t,extensions:e.extensions??DEFAULT_EXTENSIONS,conditions:e.conditions})}catch(o){i=o}if(!r&&x(n,{withExtension:!1})!=="index")try{r=resolveSync(c(n,"index"),{...e,paths:t}),r&&(r=u(r))}catch(s){i=s}if(!r)throw i??new Error(`Cannot resolve module '${n}'`);return a(r)}export async function resolveSafe(n,e={}){try{return await resolve(n,e)}catch{return}}export function resolveSafeSync(n,e={}){try{return resolveSync(n,e)}catch{return}}export async function importModule(n){const e=await import(n);return e&&y(e)}export async function resolvePackage(n,e={}){let t=await resolveSafe(c(n,"package.json"),e);return t||(t=await resolveSafe(c(n,"index.js"),e),t||(t=await resolveSafe(n,e))),t?u(t):void 0}export function resolvePackageSync(n,e={}){let t=resolveSafeSync(c(n,"package.json"),e);return t||(t=resolveSafeSync(c(n,"index.js"),e),t||(t=resolveSafeSync(n,e))),t?u(t):void 0}
1
+ import{getUnique as a}from"@stryke/helpers/get-unique";import{appendExtension as v,replacePath as p}from"@stryke/path";import{correctPath as c,toAbsolutePath as d}from"@stryke/path/correct-path";import{cwd as x}from"@stryke/path/cwd";import{findFileExtension as y,findFileName as m,findFilePath as l,findFolderName as w}from"@stryke/path/file-path-fns";import{isAbsolutePath as P,isNpmScopedPackage as g}from"@stryke/path/is-type";import{joinPaths as u}from"@stryke/path/join-paths";import{interopDefault as j,resolvePath as h,resolvePathSync as E}from"mlly";import{existsSync as R}from"./exists";import{getWorkspaceRoot as S}from"./get-workspace-root";export const DEFAULT_EXTENSIONS=["js","jsx","mjs","cjs","ts","tsx","mts","cts","json","jsonc","json5","node"];export function getResolutionPaths(n=[]){let r=n;r.includes(x())||r.push(x());const e=S();return r.includes(e)||r.push(e),r=a(r.filter(Boolean).map(s=>c(s)).reduce((s,i,t,o)=>(s.push(i),P(i)||(s.push(d(i,x())),s.push(d(i,e)),o.forEach(f=>{s.push(d(i,f))})),s),[])),r}export function getNodeModulesPaths(n=[]){return a(n.reduce((r,e)=>(w(e)==="node_modules"&&r.push(c(e)),R(u(e,"node_modules"))&&r.push(c(u(e,"node_modules"))),r),[]))}export function getResolutionCombinations(n,r={}){let e=getResolutionPaths(r.paths);g(n)?e=getNodeModulesPaths(e):e.push(...getNodeModulesPaths(e));const s=r.extensions??DEFAULT_EXTENSIONS;let i=e.map(t=>u(n,t));return m(n,{withExtension:!1})!=="index"&&(i=i.reduce((t,o)=>(t.push(o),t.push(u(o,"index")),t),[])),y(n)||(i=i.reduce((t,o)=>(t.push(o),s.forEach(f=>{t.push(v(o,f))}),t),[])),a(i.filter(Boolean)).map(t=>c(t))}export async function resolve(n,r={}){let e=getResolutionPaths(r.paths);g(n)?e=getNodeModulesPaths(e):e.push(...getNodeModulesPaths(e));let s,i;try{s=await h(n,{url:e,extensions:r.extensions??DEFAULT_EXTENSIONS,conditions:r.conditions})}catch(t){i=t}if(!s)for(let t=0;t<e.length&&!s;t++)try{s=await h(p(n,e[t]),{url:e,extensions:r.extensions??DEFAULT_EXTENSIONS,conditions:r.conditions})}catch(o){i=o}if(!s&&m(n,{withExtension:!1})!=="index")try{s=await resolve(u(n,"index"),{...r,paths:e}),s&&(s=l(s))}catch(t){i=t}if(!s)throw i??new Error(`Cannot resolve module '${n}'`);return c(s)}export function resolveSync(n,r={}){let e=getResolutionPaths(r.paths);g(n)?e=getNodeModulesPaths(e):e.push(...getNodeModulesPaths(e));let s,i;try{s=E(n,{url:e,extensions:r.extensions??DEFAULT_EXTENSIONS,conditions:r.conditions})}catch(t){i=t}if(!s)for(let t=0;t<e.length&&!s;t++)try{s=E(p(n,e[t]),{url:e,extensions:r.extensions??DEFAULT_EXTENSIONS,conditions:r.conditions})}catch(o){i=o}if(!s&&m(n,{withExtension:!1})!=="index")try{s=resolveSync(u(n,"index"),{...r,paths:e}),s&&(s=l(s))}catch(t){i=t}if(!s)throw i??new Error(`Cannot resolve module '${n}'`);return c(s)}export async function resolveSafe(n,r={}){try{return await resolve(n,r)}catch{return}}export function resolveSafeSync(n,r={}){try{return resolveSync(n,r)}catch{return}}export async function importModule(n){const r=await import(n);return r&&j(r)}export async function resolvePackage(n,r={}){let e=await resolveSafe(u(n,"package.json"),r);return e||(e=await resolveSafe(u(n,"index.js"),r),e||(e=await resolveSafe(n,r))),e?l(e):void 0}export function resolvePackageSync(n,r={}){let e=resolveSafeSync(u(n,"package.json"),r);return e||(e=resolveSafeSync(u(n,"index.js"),r),e||(e=resolveSafeSync(n,r))),e?l(e):void 0}
package/dist/tsconfig.cjs CHANGED
@@ -4,26 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.loadTsConfig = loadTsConfig;
7
+ var _toArray = require("@stryke/convert/to-array");
7
8
  var _cwd = require("@stryke/path/cwd");
8
9
  var _filePathFns = require("@stryke/path/file-path-fns");
10
+ var _isType = require("@stryke/path/is-type");
9
11
  var _joinPaths = require("@stryke/path/join-paths");
10
12
  var _defu = _interopRequireDefault(require("defu"));
11
- var _mlly = require("mlly");
12
13
  var _exists = require("./exists.cjs");
13
14
  var _json = require("./json.cjs");
15
+ var _resolve = require("./resolve.cjs");
14
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- async function loadTsConfig(e = (0, _cwd.cwd)()) {
16
- let t = e.endsWith(".json") ? e : (0, _joinPaths.joinPaths)(e, "tsconfig.json");
17
- if (!(0, _exists.existsSync)(t) && (t = await (0, _mlly.resolvePath)(e, {
18
- url: require('url').pathToFileURL(__filename).toString()
19
- }), !(0, _exists.existsSync)(t))) throw new Error(`tsconfig.json not found at ${t}. Please ensure the file exists.`);
20
- let o = await (0, _json.readJsonFile)(t);
21
- if (o?.compilerOptions?.baseUrl && (o.compilerOptions.baseUrl = (0, _joinPaths.joinPaths)((0, _filePathFns.findFilePath)(t), o.compilerOptions.baseUrl)), o?.extends) {
22
- const f = Array.isArray(o.extends) ? o.extends : [o.extends];
23
- for (const m of f) {
24
- const n = await loadTsConfig((0, _joinPaths.joinPaths)((0, _filePathFns.findFilePath)(t), m));
25
- n && (o = (0, _defu.default)(o, n ?? {}));
26
- }
17
+ async function loadTsConfig(n = (0, _cwd.cwd)()) {
18
+ let i = (0, _filePathFns.findFileExtension)(n) === "json" ? n : (0, _joinPaths.joinPaths)(n, "tsconfig.json");
19
+ if (!(0, _exists.existsSync)(i) && (i = await (0, _resolve.resolve)(n, {
20
+ extensions: ["json"]
21
+ }), !(0, _exists.existsSync)(i))) throw new Error(`tsconfig.json not found at ${i}. Please ensure the file exists.`);
22
+ let o = await (0, _json.readJsonFile)(i);
23
+ if (o?.compilerOptions?.baseUrl && (o.compilerOptions.baseUrl = (0, _joinPaths.joinPaths)((0, _filePathFns.findFilePath)(i), o.compilerOptions.baseUrl)), o?.extends) for (const e of (0, _toArray.toArray)(o.extends)) {
24
+ const t = await loadTsConfig((0, _isType.isNpmScopedPackage)(e) ? e : (0, _joinPaths.joinPaths)((0, _filePathFns.findFilePath)(i), e));
25
+ t && (o = (0, _defu.default)(o, t ?? {}));
27
26
  }
28
27
  return o.extends = void 0, o;
29
28
  }
package/dist/tsconfig.mjs CHANGED
@@ -1 +1 @@
1
- import{cwd as a}from"@stryke/path/cwd";import{findFilePath as i}from"@stryke/path/file-path-fns";import{joinPaths as s}from"@stryke/path/join-paths";import p from"defu";import{resolvePath as d}from"mlly";import{existsSync as r}from"./exists";import{readJsonFile as c}from"./json";export async function loadTsConfig(e=a()){let t=e.endsWith(".json")?e:s(e,"tsconfig.json");if(!r(t)&&(t=await d(e,{url:import.meta.url}),!r(t)))throw new Error(`tsconfig.json not found at ${t}. Please ensure the file exists.`);let o=await c(t);if(o?.compilerOptions?.baseUrl&&(o.compilerOptions.baseUrl=s(i(t),o.compilerOptions.baseUrl)),o?.extends){const f=Array.isArray(o.extends)?o.extends:[o.extends];for(const m of f){const n=await loadTsConfig(s(i(t),m));n&&(o=p(o,n??{}))}}return o.extends=void 0,o}
1
+ import{toArray as m}from"@stryke/convert/to-array";import{cwd as p}from"@stryke/path/cwd";import{findFileExtension as a,findFilePath as r}from"@stryke/path/file-path-fns";import{isNpmScopedPackage as c}from"@stryke/path/is-type";import{joinPaths as s}from"@stryke/path/join-paths";import d from"defu";import{existsSync as f}from"./exists";import{readJsonFile as l}from"./json";import{resolve as g}from"./resolve";export async function loadTsConfig(n=p()){let i=a(n)==="json"?n:s(n,"tsconfig.json");if(!f(i)&&(i=await g(n,{extensions:["json"]}),!f(i)))throw new Error(`tsconfig.json not found at ${i}. Please ensure the file exists.`);let o=await l(i);if(o?.compilerOptions?.baseUrl&&(o.compilerOptions.baseUrl=s(r(i),o.compilerOptions.baseUrl)),o?.extends)for(const e of m(o.extends)){const t=await loadTsConfig(c(e)?e:s(r(i),e));t&&(o=d(o,t??{}))}return o.extends=void 0,o}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/fs",
3
- "version": "0.33.0",
3
+ "version": "0.33.2",
4
4
  "type": "module",
5
5
  "description": "A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.",
6
6
  "repository": {
@@ -15,10 +15,10 @@
15
15
  "@antfu/install-pkg": "^1.1.0",
16
16
  "@ltd/j-toml": "^1.38.0",
17
17
  "@storm-software/config-tools": "^1.188.48",
18
- "@stryke/convert": "^0.6.5",
19
- "@stryke/helpers": "^0.9.7",
20
- "@stryke/path": "^0.20.0",
21
- "@stryke/string-format": "^0.12.5",
18
+ "@stryke/convert": "^0.6.6",
19
+ "@stryke/helpers": "^0.9.8",
20
+ "@stryke/path": "^0.21.0",
21
+ "@stryke/string-format": "^0.12.6",
22
22
  "chalk": "^5.6.2",
23
23
  "defu": "^6.1.4",
24
24
  "glob": "^11.1.0",
@@ -26,9 +26,9 @@
26
26
  "nanotar": "^0.2.0",
27
27
  "semver": "7.7.1",
28
28
  "yaml": "^2.8.1",
29
- "@stryke/json": "^0.9.8",
30
- "@stryke/type-checks": "^0.3.15",
31
- "@stryke/types": "^0.10.5"
29
+ "@stryke/json": "^0.9.9",
30
+ "@stryke/type-checks": "^0.3.16",
31
+ "@stryke/types": "^0.10.6"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^24.10.1",
@@ -410,5 +410,5 @@
410
410
  "main": "./dist/index.cjs",
411
411
  "module": "./dist/index.mjs",
412
412
  "types": "./dist/index.d.ts",
413
- "gitHead": "2c99ef0e654a63299ca75104ec2e8a46d65997cc"
413
+ "gitHead": "fc3f6e2179191455ef4c9a8e7be4294a77228b07"
414
414
  }