@visulima/fs 1.0.0 → 1.1.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## @visulima/fs [1.1.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.0.0...@visulima/fs@1.1.0) (2024-03-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * **fs:** added isAccessibleSync and isAccessible ([#339](https://github.com/visulima/visulima/issues/339)) ([552eaec](https://github.com/visulima/visulima/commit/552eaec4a1b36db08a6386c562fa6a3bf248c40d))
7
+
1
8
  ## @visulima/fs 1.0.0 (2024-03-09)
2
9
 
3
10
 
@@ -5,7 +12,7 @@
5
12
 
6
13
  * **fs:** added collect-sync ([ed76052](https://github.com/visulima/visulima/commit/ed760529d190a177c64c4028c572160da62c9a0f))
7
14
  * migrating readdir to fs package ([664d567](https://github.com/visulima/visulima/commit/664d5670ac84811963a830b594968f19bf81809a))
8
- * renamed readdir for fs ([29b0564](https://github.com/visulima/visulima/commit/29b0564913cd136cd126a1e3a6d9461a85158930))
15
+ * renamed readdir to fs ([29b0564](https://github.com/visulima/visulima/commit/29b0564913cd136cd126a1e3a6d9461a85158930))
9
16
 
10
17
 
11
18
  ### Bug Fixes
package/dist/index.d.mts CHANGED
@@ -30,8 +30,14 @@ declare const findUpSync: (name: string, options?: {
30
30
  type?: "directory" | "file";
31
31
  }) => string | undefined;
32
32
 
33
+ declare function isAccessible(path: string, mode?: number): Promise<boolean>;
34
+ declare function isAccessible(path: string[], mode?: number): Promise<boolean[]>;
35
+
36
+ declare function isAccessibleSync(path: string, mode?: number): boolean;
37
+ declare function isAccessibleSync(path: string[], mode?: number): boolean[];
38
+
33
39
  declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
34
40
 
35
41
  declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
36
42
 
37
- export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, walk, walkSync };
43
+ export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, walk, walkSync };
package/dist/index.d.ts CHANGED
@@ -30,8 +30,14 @@ declare const findUpSync: (name: string, options?: {
30
30
  type?: "directory" | "file";
31
31
  }) => string | undefined;
32
32
 
33
+ declare function isAccessible(path: string, mode?: number): Promise<boolean>;
34
+ declare function isAccessible(path: string[], mode?: number): Promise<boolean[]>;
35
+
36
+ declare function isAccessibleSync(path: string, mode?: number): boolean;
37
+ declare function isAccessibleSync(path: string[], mode?: number): boolean[];
38
+
33
39
  declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
34
40
 
35
41
  declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
36
42
 
37
- export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, walk, walkSync };
43
+ export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, walk, walkSync };
package/dist/index.js CHANGED
@@ -5,13 +5,15 @@ var path = require('path');
5
5
  var url = require('url');
6
6
  var fs = require('fs');
7
7
 
8
- var h=class extends Error{root;constructor(i,r){super(`${i instanceof Error?i.message:i} for path "${r}"`),this.cause=i,this.name="WalkError",this.root=r;}},u=h;var L=e=>{let i=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${i}$`)},g=L;var x=e=>e instanceof URL?url.fileURLToPath(e):e,m=x;var R=(e,i,r,o)=>i&&!i.some(s=>e.endsWith(s))||r&&!r.some(s=>s.test(e))?!1:!(o&&o.some(s=>s.test(e))),y=R;var T=async e=>{let i=path.normalize(e),r=path.basename(i),o=await promises.stat(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};async function*w(e,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:l=!0,match:c,maxDepth:a=Number.POSITIVE_INFINITY,skip:k}={}){if(a<0)return;let d=c?c.map(t=>typeof t=="string"?g(t):t):void 0,f=k?k.map(t=>typeof t=="string"?g(t):t):void 0;if(e=path.resolve(m(e)),o&&y(e,i,d,f)&&(yield await T(e)),!(a<1||!y(e,void 0,void 0,f)))try{for await(let t of await promises.readdir(e,{withFileTypes:!0})){let n=path.join(e,t.name);if(t.isSymbolicLink())if(r)n=await promises.realpath(n);else if(l&&y(n,i,d,f))yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n};else continue;t.isSymbolicLink()||t.isDirectory()?yield*w(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:l,match:d,maxDepth:a-1,skip:f}):t.isFile()&&s&&y(n,i,d,f)&&(yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n});}}catch(t){throw t instanceof u?t:new u(t,e)}}var A=async(e,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for await(let s of w(e,r))o.push(s.path);return o},N=A;var q=e=>{let i=path.normalize(e),r=path.basename(i),o=fs.statSync(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};function*b(e,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:l=!0,match:c,maxDepth:a=Number.POSITIVE_INFINITY,skip:k}={}){if(a<0)return;let d=c?c.map(t=>typeof t=="string"?g(t):t):void 0,f=k?k.map(t=>typeof t=="string"?g(t):t):void 0;if(e=path.resolve(m(e)),o&&y(e,i,d,f)&&(yield q(e)),!(a<1||!y(e,void 0,void 0,f)))try{for(let t of fs.readdirSync(e,{withFileTypes:!0})){let n=path.join(e,t.name);if(t.isSymbolicLink())if(r)n=fs.realpathSync(n);else if(l&&y(n,i,d,f))yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n};else continue;t.isSymbolicLink()||t.isDirectory()?yield*b(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:l,match:d,maxDepth:a-1,skip:f}):t.isFile()&&s&&y(n,i,d,f)&&(yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n});}}catch(t){throw t instanceof u?t:new u(t,e)}}var B=(e,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for(let s of b(e,r))o.push(s.path);return o},C=B;var X=async(e,i={})=>{let r=path.resolve(i.cwd?m(i.cwd):process.cwd()),{root:o}=path.parse(r),s=path.resolve(r,m(i.stopAt??o)),l=i.type??"file";for(;r&&r!==s&&r!==o;){let c=path.isAbsolute(e)?e:path.join(r,e);try{let a=await promises.stat(c);if(l==="file"&&a.isFile()||l==="directory"&&a.isDirectory())return c}catch{}r=path.dirname(r);}},Z=X;var st=(e,i={})=>{let r=path.resolve(i.cwd?m(i.cwd):process.cwd()),{root:o}=path.parse(r),s=path.resolve(r,m(i.stopAt??o)),l=i.type??"file";for(;r&&r!==s&&r!==o;){let c=path.isAbsolute(e)?e:path.join(r,e);try{let a=fs.statSync(c);if(l==="file"&&a.isFile()||l==="directory"&&a.isDirectory())return c}catch{}r=path.dirname(r);}},nt=st;
8
+ var S=class extends Error{root;constructor(i,r){super(`${i instanceof Error?i.message:i} for path "${r}"`),this.cause=i,this.name="WalkError",this.root=r;}},d=S;var W=t=>{let i=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${i}$`)},g=W;var F=t=>t instanceof URL?url.fileURLToPath(t):t,m=F;var R=(t,i,r,o)=>i&&!i.some(s=>t.endsWith(s))||r&&!r.some(s=>s.test(t))?!1:!(o&&o.some(s=>s.test(t))),y=R;var N=async t=>{let i=path.normalize(t),r=path.basename(i),o=await promises.stat(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};async function*k(t,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:c=!0,match:f,maxDepth:a=Number.POSITIVE_INFINITY,skip:b}={}){if(a<0)return;let u=f?f.map(e=>typeof e=="string"?g(e):e):void 0,p=b?b.map(e=>typeof e=="string"?g(e):e):void 0;if(t=path.resolve(m(t)),o&&y(t,i,u,p)&&(yield await N(t)),!(a<1||!y(t,void 0,void 0,p)))try{for await(let e of await promises.readdir(t,{withFileTypes:!0})){let n=path.join(t,e.name);if(e.isSymbolicLink())if(r)n=await promises.realpath(n);else if(c&&y(n,i,u,p))yield {isDirectory:e.isDirectory,isFile:e.isFile,isSymbolicLink:e.isSymbolicLink,name:e.name,path:n};else continue;e.isSymbolicLink()||e.isDirectory()?yield*k(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:c,match:u,maxDepth:a-1,skip:p}):e.isFile()&&s&&y(n,i,u,p)&&(yield {isDirectory:e.isDirectory,isFile:e.isFile,isSymbolicLink:e.isSymbolicLink,name:e.name,path:n});}}catch(e){throw e instanceof d?e:new d(e,t)}}var _=async(t,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for await(let s of k(t,r))o.push(s.path);return o},$=_;var B=t=>{let i=path.normalize(t),r=path.basename(i),o=fs.statSync(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};function*w(t,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:c=!0,match:f,maxDepth:a=Number.POSITIVE_INFINITY,skip:b}={}){if(a<0)return;let u=f?f.map(e=>typeof e=="string"?g(e):e):void 0,p=b?b.map(e=>typeof e=="string"?g(e):e):void 0;if(t=path.resolve(m(t)),o&&y(t,i,u,p)&&(yield B(t)),!(a<1||!y(t,void 0,void 0,p)))try{for(let e of fs.readdirSync(t,{withFileTypes:!0})){let n=path.join(t,e.name);if(e.isSymbolicLink())if(r)n=fs.realpathSync(n);else if(c&&y(n,i,u,p))yield {isDirectory:e.isDirectory,isFile:e.isFile,isSymbolicLink:e.isSymbolicLink,name:e.name,path:n};else continue;e.isSymbolicLink()||e.isDirectory()?yield*w(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:c,match:u,maxDepth:a-1,skip:p}):e.isFile()&&s&&y(n,i,u,p)&&(yield {isDirectory:e.isDirectory,isFile:e.isFile,isSymbolicLink:e.isSymbolicLink,name:e.name,path:n});}}catch(e){throw e instanceof d?e:new d(e,t)}}var C=(t,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for(let s of w(t,r))o.push(s.path);return o},G=C;var tt=async(t,i={})=>{let r=path.resolve(i.cwd?m(i.cwd):process.cwd()),{root:o}=path.parse(r),s=path.resolve(r,m(i.stopAt??o)),c=i.type??"file";for(;r&&r!==s&&r!==o;){let f=path.isAbsolute(t)?t:path.join(r,t);try{let a=await promises.stat(f);if(c==="file"&&a.isFile()||c==="directory"&&a.isDirectory())return f}catch{}r=path.dirname(r);}},et=tt;var at=(t,i={})=>{let r=path.resolve(i.cwd?m(i.cwd):process.cwd()),{root:o}=path.parse(r),s=path.resolve(r,m(i.stopAt??o)),c=i.type??"file";for(;r&&r!==s&&r!==o;){let f=path.isAbsolute(t)?t:path.join(r,t);try{let a=fs.statSync(f);if(c==="file"&&a.isFile()||c==="directory"&&a.isDirectory())return f}catch{}r=path.dirname(r);}},lt=at;async function E(t,i=0){if(Array.isArray(t))return await Promise.all(t.map(async r=>await E(r,i)));try{return await promises.access(t,i),!0}catch{return !1}}var pt=E;function L(t,i=0){if(Array.isArray(t))return t.map(r=>L(r,i));try{return fs.accessSync(t,i),!0}catch{return !1}}var yt=L;
9
9
 
10
- exports.collect = N;
11
- exports.collectSync = C;
12
- exports.findUp = Z;
13
- exports.findUpSync = nt;
14
- exports.walk = w;
15
- exports.walkSync = b;
10
+ exports.collect = $;
11
+ exports.collectSync = G;
12
+ exports.findUp = et;
13
+ exports.findUpSync = lt;
14
+ exports.isAccessible = pt;
15
+ exports.isAccessibleSync = yt;
16
+ exports.walk = k;
17
+ exports.walkSync = w;
16
18
  //# sourceMappingURL=out.js.map
17
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/walk.ts","../src/error/walk-error.ts","../src/utils/glob-to-regex.ts","../src/utils/to-path.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/find-up.ts","../src/find-up-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","WalkError","cause","root","walk_error_default","globToRegExp","glob","reString","glob_to_regex_default","fileURLToPath","toPath","urlOrPath","to_path_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","entry","error","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","dirname","isAbsol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AAOyB,EAAQ,GAAG,EAAI,QAAQ,IAAI,CAAC,EACnE,CAAE,KAAAlC,CAAK,EAAI8C,GAAMvB,CAAS,EAC1ByB,EAASnD,EAAQ0B,EAAWd,EAAOyB,EAAQ,QAAUlC,CAAI,CAAC,EAE1DiD,EAAOf,EAAQ,MAAQ,OAG7B,KAAOX,GAAaA,IAAcyB,GAAUzB,IAAcvB,GAAM,CAC5D,IAAMkD,EAAWL,GAAWzB,CAAI,EAAIA,EAAOzB,GAAK4B,EAAWH,CAAI,EAE/D,GAAI,CAEA,IAAM+B,EAAQX,GAASU,CAAQ,EAE/B,GAAKD,IAAS,QAAUE,EAAM,OAAO,GAAOF,IAAS,aAAeE,EAAM,YAAY,EAClF,OAAOD,CAEf,MAAQ,CAER,CAEA3B,EAAYqB,GAAQrB,CAAS,CACjC,CAGJ,EAEO+B,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): Promise<string | undefined> => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath); // eslint-disable-line no-await-in-loop\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): string | undefined => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n"]}
1
+ {"version":3,"sources":["../src/walk.ts","../src/error/walk-error.ts","../src/utils/glob-to-regex.ts","../src/utils/to-path.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/find-up.ts","../src/find-up-sync.ts","../src/is-accessible.ts","../src/is-accessible-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","WalkError","cause","root","walk_error_default","globToRegExp","glob","reString","glob_to_regex_default","fileURLToPath","toPath","urlOrPath","to_path_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","entry","error","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","dirname","isAbsolute","parse","findUp","stopAt","type","filePath","stats","find_up_default","findUpSync","find_up_sync_default","access","isAccessible","mode","index","is_accessible_default","accessSync","isAccessibleSync","is_accessible_sync_default"],"mappings":"AAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,cACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,OCDnD,IAAMC,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAO,YACZ,KAAK,KAAOC,CAChB,CACJ,EAEOC,EAAQH,ECrBf,IAAMI,EAAgBC,GAAyB,CAC3C,IAAMC,EAAWD,EAEZ,QAAQ,QAAS,UAAU,EAE3B,QAAQ,QAAS,MAAM,EAEvB,QAAQ,mBAAoB,SAAS,EAErC,QAAQ,MAAO,M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AAc,cAQvB,eAAeC,EAAa7C,EAAyB8C,EAAe,EAAoC,CACpG,GAAI,MAAM,QAAQ9C,CAAI,EAClB,OAAO,MAAM,QAAQ,IAAIA,EAAK,IAAI,MAAO+C,GAAU,MAAMF,EAAaE,EAAOD,CAAI,CAAC,CAAC,EAGvF,GAAI,CACA,aAAMF,GAAO5C,EAAM8C,CAAI,EAEhB,EACX,MAAQ,CACJ,MAAO,EACX,CACJ,CAEA,IAAOE,GAAQH,ECtBf,OAAS,cAAAI,OAAkB,KAQ3B,SAASC,EAAiBlD,EAAyB8C,EAAe,EAA2B,CACzF,GAAI,MAAM,QAAQ9C,CAAI,EAClB,OAAOA,EAAK,IAAK+C,GAAUG,EAAiBH,EAAOD,CAAI,CAAC,EAG5D,GAAI,CACA,OAAAG,GAAWjD,EAAM8C,CAAI,EAEd,EACX,MAAQ,CACJ,MAAO,EACX,CACJ,CAEA,IAAOK,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): Promise<string | undefined> => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath); // eslint-disable-line no-await-in-loop\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): string | undefined => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n","import { access } from \"node:fs/promises\";\n\nimport { F_OK } from \"./constants\";\n\n/** Returns a Promise that resolves to a boolean indicating if the path is accessible or not. */\nasync function isAccessible(path: string, mode?: number): Promise<boolean>;\nasync function isAccessible(path: string[], mode?: number): Promise<boolean[]>;\n// eslint-disable-next-line func-style\nasync function isAccessible(path: string[] | string, mode: number = F_OK): Promise<boolean[] | boolean> {\n if (Array.isArray(path)) {\n return await Promise.all(path.map(async (index) => await isAccessible(index, mode)));\n }\n\n try {\n await access(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessible;\n","import { accessSync } from \"node:fs\";\n\nimport { F_OK } from \"./constants\";\n\n/** Returns a boolean indicating if the path is accessible or not. */\nfunction isAccessibleSync(path: string, mode?: number): boolean;\nfunction isAccessibleSync(path: string[], mode?: number): boolean[];\n// eslint-disable-next-line func-style\nfunction isAccessibleSync(path: string[] | string, mode: number = F_OK): boolean[] | boolean {\n if (Array.isArray(path)) {\n return path.map((index) => isAccessibleSync(index, mode));\n }\n\n try {\n accessSync(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessibleSync;\n"]}
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { readdir, realpath, stat } from 'node:fs/promises';
1
+ import { readdir, realpath, stat, access } from 'node:fs/promises';
2
2
  import { resolve, join, normalize, basename, parse, isAbsolute, dirname } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
- import { readdirSync, realpathSync, statSync } from 'node:fs';
4
+ import { readdirSync, realpathSync, statSync, accessSync } from 'node:fs';
5
5
 
6
- var S=class extends Error{root;constructor(i,r){super(`${i instanceof Error?i.message:i} for path "${r}"`),this.cause=i,this.name="WalkError",this.root=r;}},g=S;var W=e=>{let i=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${i}$`)},k=W;var R=e=>e instanceof URL?fileURLToPath(e):e,y=R;var F=(e,i,r,o)=>i&&!i.some(s=>e.endsWith(s))||r&&!r.some(s=>s.test(e))?!1:!(o&&o.some(s=>s.test(e))),d=F;var A=async e=>{let i=normalize(e),r=basename(i),o=await stat(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};async function*b(e,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:l=!0,match:c,maxDepth:a=Number.POSITIVE_INFINITY,skip:w}={}){if(a<0)return;let u=c?c.map(t=>typeof t=="string"?k(t):t):void 0,f=w?w.map(t=>typeof t=="string"?k(t):t):void 0;if(e=resolve(y(e)),o&&d(e,i,u,f)&&(yield await A(e)),!(a<1||!d(e,void 0,void 0,f)))try{for await(let t of await readdir(e,{withFileTypes:!0})){let n=join(e,t.name);if(t.isSymbolicLink())if(r)n=await realpath(n);else if(l&&d(n,i,u,f))yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n};else continue;t.isSymbolicLink()||t.isDirectory()?yield*b(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:l,match:u,maxDepth:a-1,skip:f}):t.isFile()&&s&&d(n,i,u,f)&&(yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n});}}catch(t){throw t instanceof g?t:new g(t,e)}}var N=async(e,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for await(let s of b(e,r))o.push(s.path);return o},$=N;var B=e=>{let i=normalize(e),r=basename(i),o=statSync(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};function*h(e,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:l=!0,match:c,maxDepth:a=Number.POSITIVE_INFINITY,skip:w}={}){if(a<0)return;let u=c?c.map(t=>typeof t=="string"?k(t):t):void 0,f=w?w.map(t=>typeof t=="string"?k(t):t):void 0;if(e=resolve(y(e)),o&&d(e,i,u,f)&&(yield B(e)),!(a<1||!d(e,void 0,void 0,f)))try{for(let t of readdirSync(e,{withFileTypes:!0})){let n=join(e,t.name);if(t.isSymbolicLink())if(r)n=realpathSync(n);else if(l&&d(n,i,u,f))yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n};else continue;t.isSymbolicLink()||t.isDirectory()?yield*h(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:l,match:u,maxDepth:a-1,skip:f}):t.isFile()&&s&&d(n,i,u,f)&&(yield {isDirectory:t.isDirectory,isFile:t.isFile,isSymbolicLink:t.isSymbolicLink,name:t.name,path:n});}}catch(t){throw t instanceof g?t:new g(t,e)}}var C=(e,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for(let s of h(e,r))o.push(s.path);return o},G=C;var Z=async(e,i={})=>{let r=resolve(i.cwd?y(i.cwd):process.cwd()),{root:o}=parse(r),s=resolve(r,y(i.stopAt??o)),l=i.type??"file";for(;r&&r!==s&&r!==o;){let c=isAbsolute(e)?e:join(r,e);try{let a=await stat(c);if(l==="file"&&a.isFile()||l==="directory"&&a.isDirectory())return c}catch{}r=dirname(r);}},tt=Z;var nt=(e,i={})=>{let r=resolve(i.cwd?y(i.cwd):process.cwd()),{root:o}=parse(r),s=resolve(r,y(i.stopAt??o)),l=i.type??"file";for(;r&&r!==s&&r!==o;){let c=isAbsolute(e)?e:join(r,e);try{let a=statSync(c);if(l==="file"&&a.isFile()||l==="directory"&&a.isDirectory())return c}catch{}r=dirname(r);}},at=nt;
6
+ var h=class extends Error{root;constructor(i,r){super(`${i instanceof Error?i.message:i} for path "${r}"`),this.cause=i,this.name="WalkError",this.root=r;}},g=h;var A=t=>{let i=t.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${i}$`)},b=A;var R=t=>t instanceof URL?fileURLToPath(t):t,y=R;var I=(t,i,r,o)=>i&&!i.some(s=>t.endsWith(s))||r&&!r.some(s=>s.test(t))?!1:!(o&&o.some(s=>s.test(t))),u=I;var _=async t=>{let i=normalize(t),r=basename(i),o=await stat(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};async function*w(t,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:f=!0,match:p,maxDepth:a=Number.POSITIVE_INFINITY,skip:k}={}){if(a<0)return;let d=p?p.map(e=>typeof e=="string"?b(e):e):void 0,m=k?k.map(e=>typeof e=="string"?b(e):e):void 0;if(t=resolve(y(t)),o&&u(t,i,d,m)&&(yield await _(t)),!(a<1||!u(t,void 0,void 0,m)))try{for await(let e of await readdir(t,{withFileTypes:!0})){let n=join(t,e.name);if(e.isSymbolicLink())if(r)n=await realpath(n);else if(f&&u(n,i,d,m))yield {isDirectory:e.isDirectory,isFile:e.isFile,isSymbolicLink:e.isSymbolicLink,name:e.name,path:n};else continue;e.isSymbolicLink()||e.isDirectory()?yield*w(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:f,match:d,maxDepth:a-1,skip:m}):e.isFile()&&s&&u(n,i,d,m)&&(yield {isDirectory:e.isDirectory,isFile:e.isFile,isSymbolicLink:e.isSymbolicLink,name:e.name,path:n});}}catch(e){throw e instanceof g?e:new g(e,t)}}var $=async(t,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for await(let s of w(t,r))o.push(s.path);return o},v=$;var C=t=>{let i=normalize(t),r=basename(i),o=statSync(i);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:i}};function*S(t,{extensions:i,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:s=!0,includeSymlinks:f=!0,match:p,maxDepth:a=Number.POSITIVE_INFINITY,skip:k}={}){if(a<0)return;let d=p?p.map(e=>typeof e=="string"?b(e):e):void 0,m=k?k.map(e=>typeof e=="string"?b(e):e):void 0;if(t=resolve(y(t)),o&&u(t,i,d,m)&&(yield C(t)),!(a<1||!u(t,void 0,void 0,m)))try{for(let e of readdirSync(t,{withFileTypes:!0})){let n=join(t,e.name);if(e.isSymbolicLink())if(r)n=realpathSync(n);else if(f&&u(n,i,d,m))yield {isDirectory:e.isDirectory,isFile:e.isFile,isSymbolicLink:e.isSymbolicLink,name:e.name,path:n};else continue;e.isSymbolicLink()||e.isDirectory()?yield*S(n,{extensions:i,followSymlinks:r,includeDirs:o,includeFiles:s,includeSymlinks:f,match:d,maxDepth:a-1,skip:m}):e.isFile()&&s&&u(n,i,d,m)&&(yield {isDirectory:e.isDirectory,isFile:e.isFile,isSymbolicLink:e.isSymbolicLink,name:e.name,path:n});}}catch(e){throw e instanceof g?e:new g(e,t)}}var G=(t,i={})=>{let r={extensions:["js","mjs","cjs","ts"],...i},o=[];for(let s of S(t,r))o.push(s.path);return o},H=G;var et=async(t,i={})=>{let r=resolve(i.cwd?y(i.cwd):process.cwd()),{root:o}=parse(r),s=resolve(r,y(i.stopAt??o)),f=i.type??"file";for(;r&&r!==s&&r!==o;){let p=isAbsolute(t)?t:join(r,t);try{let a=await stat(p);if(f==="file"&&a.isFile()||f==="directory"&&a.isDirectory())return p}catch{}r=dirname(r);}},it=et;var lt=(t,i={})=>{let r=resolve(i.cwd?y(i.cwd):process.cwd()),{root:o}=parse(r),s=resolve(r,y(i.stopAt??o)),f=i.type??"file";for(;r&&r!==s&&r!==o;){let p=isAbsolute(t)?t:join(r,t);try{let a=statSync(p);if(f==="file"&&a.isFile()||f==="directory"&&a.isDirectory())return p}catch{}r=dirname(r);}},ct=lt;async function L(t,i=0){if(Array.isArray(t))return await Promise.all(t.map(async r=>await L(r,i)));try{return await access(t,i),!0}catch{return !1}}var mt=L;function W(t,i=0){if(Array.isArray(t))return t.map(r=>W(r,i));try{return accessSync(t,i),!0}catch{return !1}}var ut=W;
7
7
 
8
- export { $ as collect, G as collectSync, tt as findUp, at as findUpSync, b as walk, h as walkSync };
8
+ export { v as collect, H as collectSync, it as findUp, ct as findUpSync, mt as isAccessible, ut as isAccessibleSync, w as walk, S as walkSync };
9
9
  //# sourceMappingURL=out.js.map
10
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/walk.ts","../src/error/walk-error.ts","../src/utils/glob-to-regex.ts","../src/utils/to-path.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/find-up.ts","../src/find-up-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","WalkError","cause","root","walk_error_default","globToRegExp","glob","reString","glob_to_regex_default","fileURLToPath","toPath","urlOrPath","to_path_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","entry","error","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","dirname","isAbsolute","parse","findUp","stopAt","type","filePath","stats","find_up_default","findUpSync","find_up_sync_default"],"mappings":"AAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,mBACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAA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AI,CAAC,EAE1DiD,EAAOf,EAAQ,MAAQ,OAG7B,KAAOX,GAAaA,IAAcyB,GAAUzB,IAAcvB,GAAM,CAC5D,IAAMkD,EAAWL,GAAWzB,CAAI,EAAIA,EAAOzB,GAAK4B,EAAWH,CAAI,EAE/D,GAAI,CAEA,IAAM+B,EAAQX,GAASU,CAAQ,EAE/B,GAAKD,IAAS,QAAUE,EAAM,OAAO,GAAOF,IAAS,aAAeE,EAAM,YAAY,EAClF,OAAOD,CAEf,MAAQ,CAER,CAEA3B,EAAYqB,GAAQrB,CAAS,CACjC,CAGJ,EAEO+B,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): Promise<string | undefined> => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath); // eslint-disable-line no-await-in-loop\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): string | undefined => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n"]}
1
+ {"version":3,"sources":["../src/walk.ts","../src/error/walk-error.ts","../src/utils/glob-to-regex.ts","../src/utils/to-path.ts","../src/utils/walk-include.ts","../src/collect.ts","../src/walk-sync.ts","../src/collect-sync.ts","../src/find-up.ts","../src/find-up-sync.ts","../src/is-accessible.ts","../src/is-accessible-sync.ts"],"names":["readdir","realpath","stat","basename","join","normalize","resolve","WalkError","cause","root","walk_error_default","globToRegExp","glob","reString","glob_to_regex_default","fileURLToPath","toPath","urlOrPath","to_path_default","walkInclude","path","extensions","match","skip","extension","pattern","walk_include_default","_createWalkEntry","normalizePath","name","info","walk","directory","followSymlinks","includeDirectories","includeFiles","includeSymlinks","maxDepth","mappedMatch","mappedSkip","entry","error","collect","options","config","entries","collect_default","readdirSync","realpathSync","statSync","walkSync","collectSync","collect_sync_default","dirname","isAbsolute","parse","findUp","stopAt","type","filePath","stats","find_up_default","findUpSync","find_up_sync_default","access","isAccessible","mode","index","is_accessible_default","accessSync","isAccessibleSync","is_accessible_sync_default"],"mappings":"AAMA,OAAS,WAAAA,EAAS,YAAAC,EAAU,QAAAC,MAAY,mBACxC,OAAS,YAAAC,EAAU,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,YCDnD,IAAMC,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAO,YACZ,KAAK,KAAOC,CAChB,CACJ,EAEOC,EAAQH,ECrBf,IAAMI,EAAgBC,GAAyB,CAC3C,IAAMC,EAAWD,EAEZ,QAAQ,QAAS,UAAU,EAE3B,QAAQ,QAAS,MAAM,EAEvB,QAAQ,mBAAoB,SAAS,EAErC,QAAQ,MAAO,MAAM,EAErB,QAAQ,YAAa,KAAK,EAE1B,QAAQ,MAAO,GAAG,EAElB,QAAQ,MAAO,GAAG,EAElB,QAAQ,KAAM,GAAG,EAEjB,QAAQ,cAAe,OAAO,EAGnC,OAAO,IAAI,O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AAaE,EAAOD,CAAI,CAAC,CAAC,EAGvF,GAAI,CACA,aAAMF,GAAO5C,EAAM8C,CAAI,EAEhB,EACX,MAAQ,CACJ,MAAO,EACX,CACJ,CAEA,IAAOE,GAAQH,ECtBf,OAAS,cAAAI,OAAkB,UAQ3B,SAASC,EAAiBlD,EAAyB8C,EAAe,EAA2B,CACzF,GAAI,MAAM,QAAQ9C,CAAI,EAClB,OAAOA,EAAK,IAAK+C,GAAUG,EAAiBH,EAAOD,CAAI,CAAC,EAG5D,GAAI,CACA,OAAAG,GAAWjD,EAAM8C,CAAI,EAEd,EACX,MAAQ,CACJ,MAAO,EACX,CACJ,CAEA,IAAOK,GAAQD","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = async (path: string): Promise<WalkEntry> => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = await stat(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/**\n * Walks the file tree rooted at root, yielding each file or directory in the\n * tree filtered according to the given options.\n * Options:\n * - maxDepth?: number = Infinity;\n * - includeFiles?: boolean = true;\n * - includeDirs?: boolean = true;\n * - includeSymlinks?: boolean = true;\n * - followSymlinks?: boolean = false;\n * - extensions?: string[];\n * - match?: string | ReadonlyArray<string>;\n * - skip?: string | ReadonlyArray<string>;\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default async function* walk(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): AsyncIterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield await _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,security/detect-non-literal-fs-filename,no-loops/no-loops\n for await (const entry of await readdir(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = await realpath(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walk(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","const globToRegExp = (glob: string): RegExp => {\n const reString = glob\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.\\*/g, \".([^/]*)\") // Replace .* with .([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\*\\*/g, \"(.*)\") // Replace ** with (.*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/(?<!\\.)\\*(?!\\*)/g, \"([^/]*)\") // Replace * (not preceded by . or followed by *) with ([^/]*)\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\?/g, \"[^/]\") // Replace ? with [^/]\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\.(?!\\*)/g, \"\\\\.\") // Escape . that is not preceded by *\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\{/g, \"(\") // Replace { with (\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\}/g, \")\") // Replace } with )\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/,/g, \"|\") // Replace , with |\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n .replace(/\\[!(.*?)\\]/g, \"[^$1]\"); // Replace [!number-number] with [^number-number]\n\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp,security/detect-non-literal-regexp\n return new RegExp(`^${reString}$`);\n};\n\nexport default globToRegExp;\n","import { fileURLToPath } from \"node:url\";\n\nconst toPath = (urlOrPath: URL | string): string => (urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);\n\nexport default toPath;\n","const walkInclude = (path: string, extensions?: string[], match?: RegExp[], skip?: RegExp[]): boolean => {\n if (extensions && !extensions.some((extension): boolean => path.endsWith(extension))) {\n return false;\n }\n\n if (match && !match.some((pattern): boolean => pattern.test(path))) {\n return false;\n }\n\n return !(skip && skip.some((pattern): boolean => pattern.test(path)));\n};\n\nexport default walkInclude;\n","import type { WalkOptions } from \"./types\";\nimport walk from \"./walk\";\n\nconst collect = async (directory: string, options: WalkOptions = {}): Promise<string[]> => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for await (const entry of walk(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collect;\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\nimport type { Stats } from \"node:fs\";\nimport { readdirSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, join, normalize, resolve } from \"node:path\";\n\nimport WalkError from \"./error/walk-error\";\nimport type { WalkEntry, WalkOptions } from \"./types\";\nimport globToRegExp from \"./utils/glob-to-regex\";\nimport toPath from \"./utils/to-path\";\nimport walkInclude from \"./utils/walk-include\";\n\n/** Create {@linkcode WalkEntry} for the `path` synchronously. */\n// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle\nconst _createWalkEntry = (path: string): WalkEntry => {\n const normalizePath: string = normalize(path as string);\n\n const name = basename(normalizePath);\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const info: Stats = statSync(normalizePath);\n\n return {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: info.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: info.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: info.isSymbolicLink,\n name,\n path: normalizePath,\n };\n};\n\n/** Same as {@linkcode walk} but uses synchronous ops */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function* walkSync(\n directory: URL | string,\n {\n extensions,\n followSymlinks = false,\n includeDirs: includeDirectories = true,\n includeFiles = true,\n includeSymlinks = true,\n match,\n maxDepth = Number.POSITIVE_INFINITY,\n skip,\n }: WalkOptions = {},\n): IterableIterator<WalkEntry> {\n if (maxDepth < 0) {\n return;\n }\n\n const mappedMatch = match ? match.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n const mappedSkip = skip ? skip.map((pattern): RegExp => (typeof pattern === \"string\" ? globToRegExp(pattern) : pattern)) : undefined;\n\n // eslint-disable-next-line no-param-reassign\n directory = resolve(toPath(directory));\n\n if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {\n yield _createWalkEntry(directory);\n }\n\n if (maxDepth < 1 || !walkInclude(directory, undefined, undefined, mappedSkip)) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops,security/detect-non-literal-fs-filename\n for (const entry of readdirSync(directory, {\n withFileTypes: true,\n })) {\n let path = join(directory, entry.name);\n\n if (entry.isSymbolicLink()) {\n if (followSymlinks) {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n path = realpathSync(path);\n } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n } else {\n // eslint-disable-next-line no-continue\n continue;\n }\n }\n\n if (entry.isSymbolicLink() || entry.isDirectory()) {\n yield* walkSync(path, {\n extensions,\n followSymlinks,\n includeDirs: includeDirectories,\n includeFiles,\n includeSymlinks,\n match: mappedMatch,\n maxDepth: maxDepth - 1,\n skip: mappedSkip,\n } as WalkOptions);\n } else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {\n yield {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isDirectory: entry.isDirectory,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isFile: entry.isFile,\n // eslint-disable-next-line @typescript-eslint/unbound-method\n isSymbolicLink: entry.isSymbolicLink,\n name: entry.name,\n path,\n };\n }\n }\n } catch (error) {\n if (error instanceof WalkError) {\n throw error;\n }\n\n throw new WalkError(error, directory);\n }\n}\n","import type { WalkOptions } from \"./types\";\nimport walkSync from \"./walk-sync\";\n\nconst collectSync = (directory: string, options: WalkOptions = {}): string[] => {\n const config = {\n extensions: [\"js\", \"mjs\", \"cjs\", \"ts\"],\n ...options,\n } as WalkOptions;\n\n const entries: string[] = [];\n\n // eslint-disable-next-line no-restricted-syntax,no-loops/no-loops\n for (const entry of walkSync(directory, config)) {\n entries.push(entry.path);\n }\n\n return entries;\n};\n\nexport default collectSync;\n","import { stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUp = async (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): Promise<string | undefined> => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = await stat(filePath); // eslint-disable-line no-await-in-loop\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUp;\n","import { statSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, resolve } from \"node:path\";\n\nimport toPath from \"./utils/to-path\";\n\nconst findUpSync = (\n name: string,\n options: {\n cwd?: URL | string;\n stopAt?: URL | string;\n type?: \"directory\" | \"file\";\n } = {},\n): string | undefined => {\n let directory = resolve(options.cwd ? toPath(options.cwd) : process.cwd());\n const { root } = parse(directory);\n const stopAt = resolve(directory, toPath(options.stopAt ?? root));\n\n const type = options.type ?? \"file\";\n\n // eslint-disable-next-line no-loops/no-loops\n while (directory && directory !== stopAt && directory !== root) {\n const filePath = isAbsolute(name) ? name : join(directory, name);\n\n try {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const stats = statSync(filePath);\n\n if ((type === \"file\" && stats.isFile()) || (type === \"directory\" && stats.isDirectory())) {\n return filePath;\n }\n } catch {\n /* empty */\n }\n\n directory = dirname(directory);\n }\n\n return undefined;\n};\n\nexport default findUpSync;\n","import { access } from \"node:fs/promises\";\n\nimport { F_OK } from \"./constants\";\n\n/** Returns a Promise that resolves to a boolean indicating if the path is accessible or not. */\nasync function isAccessible(path: string, mode?: number): Promise<boolean>;\nasync function isAccessible(path: string[], mode?: number): Promise<boolean[]>;\n// eslint-disable-next-line func-style\nasync function isAccessible(path: string[] | string, mode: number = F_OK): Promise<boolean[] | boolean> {\n if (Array.isArray(path)) {\n return await Promise.all(path.map(async (index) => await isAccessible(index, mode)));\n }\n\n try {\n await access(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessible;\n","import { accessSync } from \"node:fs\";\n\nimport { F_OK } from \"./constants\";\n\n/** Returns a boolean indicating if the path is accessible or not. */\nfunction isAccessibleSync(path: string, mode?: number): boolean;\nfunction isAccessibleSync(path: string[], mode?: number): boolean[];\n// eslint-disable-next-line func-style\nfunction isAccessibleSync(path: string[] | string, mode: number = F_OK): boolean[] | boolean {\n if (Array.isArray(path)) {\n return path.map((index) => isAccessibleSync(index, mode));\n }\n\n try {\n accessSync(path, mode);\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport default isAccessibleSync;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/fs",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Human friendly file system utilities for Node.js",
5
5
  "keywords": [
6
6
  "anolilab",