@visulima/fs 1.1.0 → 1.2.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 +7 -0
- package/README.md +120 -0
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## @visulima/fs [1.2.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.1.0...@visulima/fs@1.2.0) (2024-03-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* added readFile and readFileSync ([#340](https://github.com/visulima/visulima/issues/340)) ([47dd800](https://github.com/visulima/visulima/commit/47dd800cbadc8d353e9546487fa4c288d3f8be79))
|
|
7
|
+
|
|
1
8
|
## @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
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -221,6 +221,126 @@ Default: Root directory
|
|
|
221
221
|
|
|
222
222
|
A directory path where the search halts if no matches are found before reaching this point.
|
|
223
223
|
|
|
224
|
+
## readFile
|
|
225
|
+
|
|
226
|
+
Read a file.
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { readFile } from "@visulima/fs";
|
|
230
|
+
|
|
231
|
+
// Returns a Promise for the file contents.
|
|
232
|
+
const file = await readFile("package.json");
|
|
233
|
+
|
|
234
|
+
console.log(file);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## readFileSync
|
|
238
|
+
|
|
239
|
+
Read a file.
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { readFileSync } from "@visulima/fs";
|
|
243
|
+
|
|
244
|
+
// Returns the file contents.
|
|
245
|
+
|
|
246
|
+
const file = readFileSync("package.json");
|
|
247
|
+
|
|
248
|
+
console.log(file);
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### API for `readFile` and `readFileSync`
|
|
252
|
+
|
|
253
|
+
#### path
|
|
254
|
+
|
|
255
|
+
Type: `string`
|
|
256
|
+
|
|
257
|
+
The path to the file to read.
|
|
258
|
+
|
|
259
|
+
#### options
|
|
260
|
+
|
|
261
|
+
Type: `object`
|
|
262
|
+
|
|
263
|
+
##### buffer
|
|
264
|
+
|
|
265
|
+
Type: `boolean`
|
|
266
|
+
|
|
267
|
+
Default: `true`
|
|
268
|
+
|
|
269
|
+
Optional: `true`
|
|
270
|
+
|
|
271
|
+
Description: Indicates whether the file contents should be returned as a Buffer or a string.
|
|
272
|
+
|
|
273
|
+
##### compression
|
|
274
|
+
|
|
275
|
+
Type: `"brotli" | "gzip" | undefined`
|
|
276
|
+
|
|
277
|
+
Default: `undefined`
|
|
278
|
+
|
|
279
|
+
Optional: `true`
|
|
280
|
+
|
|
281
|
+
Description: The file compression.
|
|
282
|
+
|
|
283
|
+
##### encoding
|
|
284
|
+
|
|
285
|
+
Type: `"ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le" | undefined`
|
|
286
|
+
|
|
287
|
+
Default: `utf8`
|
|
288
|
+
|
|
289
|
+
Optional: `true`
|
|
290
|
+
|
|
291
|
+
#### flag
|
|
292
|
+
|
|
293
|
+
Type: `number | string | undefined`
|
|
294
|
+
|
|
295
|
+
Default: `'r'`
|
|
296
|
+
|
|
297
|
+
Optional: `true`
|
|
298
|
+
|
|
299
|
+
## isAccessible
|
|
300
|
+
|
|
301
|
+
Check if a file or directory exists and is accessible.
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
import { isAccessible } from "@visulima/fs";
|
|
305
|
+
|
|
306
|
+
// Returns a Promise for the result.
|
|
307
|
+
const file = await isAccessible("package.json");
|
|
308
|
+
|
|
309
|
+
console.log(file);
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## isAccessibleSync
|
|
313
|
+
|
|
314
|
+
Check if a file or directory exists and is accessible.
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
import { isAccessibleSync } from "@visulima/fs";
|
|
318
|
+
|
|
319
|
+
// Returns the result.
|
|
320
|
+
|
|
321
|
+
const file = isAccessibleSync("package.json");
|
|
322
|
+
|
|
323
|
+
console.log(file);
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### API for `isAccessible` and `isAccessibleSync`
|
|
327
|
+
|
|
328
|
+
#### path
|
|
329
|
+
|
|
330
|
+
Type: `string`
|
|
331
|
+
|
|
332
|
+
The path to the file or directory to check.
|
|
333
|
+
|
|
334
|
+
#### mode
|
|
335
|
+
|
|
336
|
+
Type: `number`
|
|
337
|
+
|
|
338
|
+
Default: `fs.constants.F_OK`
|
|
339
|
+
|
|
340
|
+
Optional: `true`
|
|
341
|
+
|
|
342
|
+
Description: The accessibility mode.
|
|
343
|
+
|
|
224
344
|
## Supported Node.js Versions
|
|
225
345
|
|
|
226
346
|
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,15 @@ interface WalkOptions {
|
|
|
13
13
|
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
|
|
14
14
|
path: string;
|
|
15
15
|
}
|
|
16
|
+
type ReadFileOptions<C> = {
|
|
17
|
+
buffer?: boolean;
|
|
18
|
+
compression?: C;
|
|
19
|
+
encoding?: "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le" | undefined;
|
|
20
|
+
flag?: number | string | undefined;
|
|
21
|
+
};
|
|
22
|
+
type ContentType<O = undefined> = O extends {
|
|
23
|
+
buffer: true;
|
|
24
|
+
} ? Buffer : string;
|
|
16
25
|
|
|
17
26
|
declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
|
|
18
27
|
|
|
@@ -36,8 +45,12 @@ declare function isAccessible(path: string[], mode?: number): Promise<boolean[]>
|
|
|
36
45
|
declare function isAccessibleSync(path: string, mode?: number): boolean;
|
|
37
46
|
declare function isAccessibleSync(path: string[], mode?: number): boolean[];
|
|
38
47
|
|
|
48
|
+
declare const readFile: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: string, options?: O) => Promise<ContentType<O> | undefined>;
|
|
49
|
+
|
|
50
|
+
declare const readFileSync: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: string, options?: O) => ContentType<O> | undefined;
|
|
51
|
+
|
|
39
52
|
declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
|
|
40
53
|
|
|
41
54
|
declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
|
|
42
55
|
|
|
43
|
-
export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, walk, walkSync };
|
|
56
|
+
export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, readFile, readFileSync, walk, walkSync };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,15 @@ interface WalkOptions {
|
|
|
13
13
|
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
|
|
14
14
|
path: string;
|
|
15
15
|
}
|
|
16
|
+
type ReadFileOptions<C> = {
|
|
17
|
+
buffer?: boolean;
|
|
18
|
+
compression?: C;
|
|
19
|
+
encoding?: "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le" | undefined;
|
|
20
|
+
flag?: number | string | undefined;
|
|
21
|
+
};
|
|
22
|
+
type ContentType<O = undefined> = O extends {
|
|
23
|
+
buffer: true;
|
|
24
|
+
} ? Buffer : string;
|
|
16
25
|
|
|
17
26
|
declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
|
|
18
27
|
|
|
@@ -36,8 +45,12 @@ declare function isAccessible(path: string[], mode?: number): Promise<boolean[]>
|
|
|
36
45
|
declare function isAccessibleSync(path: string, mode?: number): boolean;
|
|
37
46
|
declare function isAccessibleSync(path: string[], mode?: number): boolean[];
|
|
38
47
|
|
|
48
|
+
declare const readFile: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: string, options?: O) => Promise<ContentType<O> | undefined>;
|
|
49
|
+
|
|
50
|
+
declare const readFileSync: <O extends ReadFileOptions<"brotli" | "gzip" | "none"> | undefined = undefined>(path: string, options?: O) => ContentType<O> | undefined;
|
|
51
|
+
|
|
39
52
|
declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
|
|
40
53
|
|
|
41
54
|
declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
|
|
42
55
|
|
|
43
|
-
export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, walk, walkSync };
|
|
56
|
+
export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, readFile, readFileSync, walk, walkSync };
|
package/dist/index.js
CHANGED
|
@@ -4,16 +4,19 @@ var promises = require('fs/promises');
|
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var url = require('url');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
+
var zlib = require('zlib');
|
|
7
8
|
|
|
8
|
-
var
|
|
9
|
+
var h=class extends Error{root;constructor(t,r){super(`${t instanceof Error?t.message:t} for path "${r}"`),this.cause=t,this.name="WalkError",this.root=r;}},g=h;var E=e=>{let t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},b=E;var L=e=>e instanceof URL?url.fileURLToPath(e):e,d=L;var W=(e,t,r,o)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(o&&o.some(n=>n.test(e))),y=W;var z=async e=>{let t=path.normalize(e),r=path.basename(t),o=await promises.stat(t);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:t}};async function*k(e,{extensions:t,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:a=!0,match:c,maxDepth:s=Number.POSITIVE_INFINITY,skip:u}={}){if(s<0)return;let p=c?c.map(i=>typeof i=="string"?b(i):i):void 0,m=u?u.map(i=>typeof i=="string"?b(i):i):void 0;if(e=path.resolve(d(e)),o&&y(e,t,p,m)&&(yield await z(e)),!(s<1||!y(e,void 0,void 0,m)))try{for await(let i of await promises.readdir(e,{withFileTypes:!0})){let l=path.join(e,i.name);if(i.isSymbolicLink())if(r)l=await promises.realpath(l);else if(a&&y(l,t,p,m))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:l};else continue;i.isSymbolicLink()||i.isDirectory()?yield*k(l,{extensions:t,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:a,match:p,maxDepth:s-1,skip:m}):i.isFile()&&n&&y(l,t,p,m)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:l});}}catch(i){throw i instanceof g?i:new g(i,e)}}var C=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},o=[];for await(let n of k(e,r))o.push(n.path);return o},M=C;var Y=e=>{let t=path.normalize(e),r=path.basename(t),o=fs.statSync(t);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:t}};function*S(e,{extensions:t,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:a=!0,match:c,maxDepth:s=Number.POSITIVE_INFINITY,skip:u}={}){if(s<0)return;let p=c?c.map(i=>typeof i=="string"?b(i):i):void 0,m=u?u.map(i=>typeof i=="string"?b(i):i):void 0;if(e=path.resolve(d(e)),o&&y(e,t,p,m)&&(yield Y(e)),!(s<1||!y(e,void 0,void 0,m)))try{for(let i of fs.readdirSync(e,{withFileTypes:!0})){let l=path.join(e,i.name);if(i.isSymbolicLink())if(r)l=fs.realpathSync(l);else if(a&&y(l,t,p,m))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:l};else continue;i.isSymbolicLink()||i.isDirectory()?yield*S(l,{extensions:t,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:a,match:p,maxDepth:s-1,skip:m}):i.isFile()&&n&&y(l,t,p,m)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:l});}}catch(i){throw i instanceof g?i:new g(i,e)}}var q=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},o=[];for(let n of S(e,r))o.push(n.path);return o},G=q;var ee=async(e,t={})=>{let r=path.resolve(t.cwd?d(t.cwd):process.cwd()),{root:o}=path.parse(r),n=path.resolve(r,d(t.stopAt??o)),a=t.type??"file";for(;r&&r!==n&&r!==o;){let c=path.isAbsolute(e)?e:path.join(r,e);try{let s=await promises.stat(c);if(a==="file"&&s.isFile()||a==="directory"&&s.isDirectory())return c}catch{}r=path.dirname(r);}},te=ee;var ae=(e,t={})=>{let r=path.resolve(t.cwd?d(t.cwd):process.cwd()),{root:o}=path.parse(r),n=path.resolve(r,d(t.stopAt??o)),a=t.type??"file";for(;r&&r!==n&&r!==o;){let c=path.isAbsolute(e)?e:path.join(r,e);try{let s=fs.statSync(c);if(a==="file"&&s.isFile()||a==="directory"&&s.isDirectory())return c}catch{}r=path.dirname(r);}},ce=ae;async function F(e,t=0){if(Array.isArray(e))return await Promise.all(e.map(async r=>await F(r,t)));try{return await promises.access(e,t),!0}catch{return !1}}var pe=F;function O(e,t=0){if(Array.isArray(e))return e.map(r=>O(r,t));try{return fs.accessSync(e,t),!0}catch{return !1}}var de=O;var be={brotli:zlib.brotliDecompress,gzip:zlib.unzip,none:(e,t)=>{t(null,e);}},ke=async(e,t)=>{let{buffer:r,compression:o,encoding:n,flag:a}=t??{};return await promises.readFile(e,a?{encoding:n,flag:a}:{encoding:n}).then(async c=>await new Promise(s=>{be[o??"none"](c,(u,p)=>{s(u?void 0:r?p:p.toString());});})).catch(()=>{})},Se=ke;var Fe={brotli:zlib.brotliDecompressSync,gzip:zlib.unzipSync,none:e=>e},Oe=(e,t)=>{let{buffer:r,compression:o,encoding:n,flag:a}=t??{};try{let c=fs.readFileSync(e,a?{encoding:n,flag:a}:{encoding:n}),s=Fe[o??"none"](c);return r?s:s.toString()}catch{return}},Ee=Oe;
|
|
9
10
|
|
|
10
|
-
exports.collect =
|
|
11
|
+
exports.collect = M;
|
|
11
12
|
exports.collectSync = G;
|
|
12
|
-
exports.findUp =
|
|
13
|
-
exports.findUpSync =
|
|
14
|
-
exports.isAccessible =
|
|
15
|
-
exports.isAccessibleSync =
|
|
13
|
+
exports.findUp = te;
|
|
14
|
+
exports.findUpSync = ce;
|
|
15
|
+
exports.isAccessible = pe;
|
|
16
|
+
exports.isAccessibleSync = de;
|
|
17
|
+
exports.readFile = Se;
|
|
18
|
+
exports.readFileSync = Ee;
|
|
16
19
|
exports.walk = k;
|
|
17
|
-
exports.walkSync =
|
|
20
|
+
exports.walkSync = S;
|
|
18
21
|
//# sourceMappingURL=out.js.map
|
|
19
22
|
//# 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","../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,UAA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A3B,EAAYqB,GAAQrB,CAAS,CACjC,CAGJ,EAEO+B,GAAQD,GCxCf,OAAS,UAAAE,OAAc,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"]}
|
|
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","../src/read-file.ts","../src/read-file-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","nodeReadFile","brotliDecompress","unzip","decompressionMethods","buffer","callback","readFile","compression","encoding","flag","content","result","read_file_default","nodeReadFileSync","brotliDecompressSync","unzipSync","readFileSync","decompressed","read_file_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,MAAM,EAErB,QAAQ,YAAa,KAAK,EAE1B,QAAQ,MAAO,GAAG,EAElB,QAAQ,MAAO,GAAG,EAElB,QAAQ,KAAM,GAAG,EAEjB,QAAQ,cAAe,OAAO,EAGnC,OAAO,IAAI,OAAO,IAAIC,CAAQ,GAAG,CACrC,EAEOC,EAAQH,ECzBf,OAAS,iBAAAI,MAAqB,MAE9B,IAAMC,EAAUC,GA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AAU,KAAAC,CAAK,EAAItC,GAAW,CAAC,EAE5D,GAAI,CAGA,IAAMuC,EAAUG,GAAiBjE,EAAM6D,EAAO,CAAE,SAAAD,EAAU,KAAAC,CAAK,EAAI,CAAE,SAAAD,CAAS,CAAC,EAEzES,EAAed,GAAqBI,GAAe,MAAM,EAAEG,CAAO,EAExE,OAAQN,EAASa,EAAeA,EAAa,SAAS,CAC1D,MAAQ,CACJ,MACJ,CACJ,EAEOC,GAAQF","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","import { readFile as nodeReadFile } from \"node:fs/promises\";\nimport { brotliDecompress, unzip } from \"node:zlib\";\n\nimport type { ContentType, ReadFileOptions } from \"./types\";\n\nconst decompressionMethods = {\n brotli: brotliDecompress,\n gzip: unzip,\n none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => {\n callback(null, buffer);\n },\n} as const;\n\nconst readFile = async <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: string,\n options?: O,\n): Promise<ContentType<O> | undefined> => {\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n return await nodeReadFile(path, flag ? { encoding, flag } : { encoding })\n .then(\n async (content) =>\n // eslint-disable-next-line compat/compat\n await new Promise<ContentType<O> | undefined>((resolve) => {\n decompressionMethods[compression ?? \"none\"](content, (error, result) => {\n if (error) {\n resolve(undefined);\n } else {\n resolve((buffer ? result : result.toString()) as ContentType<O>);\n }\n });\n }),\n )\n .catch(() => undefined);\n};\n\nexport default readFile;\n","import { readFileSync as nodeReadFileSync } from \"node:fs\";\nimport { brotliDecompressSync, unzipSync } from \"node:zlib\";\n\nimport type { ContentType, ReadFileOptions } from \"./types\";\n\nconst decompressionMethods = {\n brotli: brotliDecompressSync,\n gzip: unzipSync,\n none: (buffer: Buffer) => buffer,\n} as const;\n\nconst readFileSync = <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: string,\n options?: O,\n): ContentType<O> | undefined => {\n const { buffer, compression, encoding, flag } = options ?? {};\n\n try {\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const content = nodeReadFileSync(path, flag ? { encoding, flag } : { encoding });\n\n const decompressed = decompressionMethods[compression ?? \"none\"](content);\n\n return (buffer ? decompressed : decompressed.toString()) as ContentType<O>;\n } catch {\n return undefined;\n }\n};\n\nexport default readFileSync;\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { readdir, realpath, stat, access } from 'node:fs/promises';
|
|
1
|
+
import { readdir, realpath, stat, access, readFile } 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, accessSync } from 'node:fs';
|
|
4
|
+
import { readdirSync, realpathSync, statSync, accessSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
|
|
5
6
|
|
|
6
|
-
var
|
|
7
|
+
var w=class extends Error{root;constructor(t,r){super(`${t instanceof Error?t.message:t} for path "${r}"`),this.cause=t,this.name="WalkError",this.root=r;}},b=w;var R=e=>{let t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},k=R;var W=e=>e instanceof URL?fileURLToPath(e):e,y=W;var A=(e,t,r,o)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(o&&o.some(n=>n.test(e))),u=A;var C=async e=>{let t=normalize(e),r=basename(t),o=await stat(t);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:t}};async function*S(e,{extensions:t,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:a=!0,match:c,maxDepth:s=Number.POSITIVE_INFINITY,skip:g}={}){if(s<0)return;let m=c?c.map(i=>typeof i=="string"?k(i):i):void 0,d=g?g.map(i=>typeof i=="string"?k(i):i):void 0;if(e=resolve(y(e)),o&&u(e,t,m,d)&&(yield await C(e)),!(s<1||!u(e,void 0,void 0,d)))try{for await(let i of await readdir(e,{withFileTypes:!0})){let l=join(e,i.name);if(i.isSymbolicLink())if(r)l=await realpath(l);else if(a&&u(l,t,m,d))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:l};else continue;i.isSymbolicLink()||i.isDirectory()?yield*S(l,{extensions:t,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:a,match:m,maxDepth:s-1,skip:d}):i.isFile()&&n&&u(l,t,m,d)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:l});}}catch(i){throw i instanceof b?i:new b(i,e)}}var M=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},o=[];for await(let n of S(e,r))o.push(n.path);return o},N=M;var q=e=>{let t=normalize(e),r=basename(t),o=statSync(t);return {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:r,path:t}};function*h(e,{extensions:t,followSymlinks:r=!1,includeDirs:o=!0,includeFiles:n=!0,includeSymlinks:a=!0,match:c,maxDepth:s=Number.POSITIVE_INFINITY,skip:g}={}){if(s<0)return;let m=c?c.map(i=>typeof i=="string"?k(i):i):void 0,d=g?g.map(i=>typeof i=="string"?k(i):i):void 0;if(e=resolve(y(e)),o&&u(e,t,m,d)&&(yield q(e)),!(s<1||!u(e,void 0,void 0,d)))try{for(let i of readdirSync(e,{withFileTypes:!0})){let l=join(e,i.name);if(i.isSymbolicLink())if(r)l=realpathSync(l);else if(a&&u(l,t,m,d))yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:l};else continue;i.isSymbolicLink()||i.isDirectory()?yield*h(l,{extensions:t,followSymlinks:r,includeDirs:o,includeFiles:n,includeSymlinks:a,match:m,maxDepth:s-1,skip:d}):i.isFile()&&n&&u(l,t,m,d)&&(yield {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:i.name,path:l});}}catch(i){throw i instanceof b?i:new b(i,e)}}var G=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},o=[];for(let n of h(e,r))o.push(n.path);return o},H=G;var te=async(e,t={})=>{let r=resolve(t.cwd?y(t.cwd):process.cwd()),{root:o}=parse(r),n=resolve(r,y(t.stopAt??o)),a=t.type??"file";for(;r&&r!==n&&r!==o;){let c=isAbsolute(e)?e:join(r,e);try{let s=await stat(c);if(a==="file"&&s.isFile()||a==="directory"&&s.isDirectory())return c}catch{}r=dirname(r);}},ie=te;var ce=(e,t={})=>{let r=resolve(t.cwd?y(t.cwd):process.cwd()),{root:o}=parse(r),n=resolve(r,y(t.stopAt??o)),a=t.type??"file";for(;r&&r!==n&&r!==o;){let c=isAbsolute(e)?e:join(r,e);try{let s=statSync(c);if(a==="file"&&s.isFile()||a==="directory"&&s.isDirectory())return c}catch{}r=dirname(r);}},le=ce;async function O(e,t=0){if(Array.isArray(e))return await Promise.all(e.map(async r=>await O(r,t)));try{return await access(e,t),!0}catch{return !1}}var me=O;function E(e,t=0){if(Array.isArray(e))return e.map(r=>E(r,t));try{return accessSync(e,t),!0}catch{return !1}}var ye=E;var ke={brotli:brotliDecompress,gzip:unzip,none:(e,t)=>{t(null,e);}},Se=async(e,t)=>{let{buffer:r,compression:o,encoding:n,flag:a}=t??{};return await readFile(e,a?{encoding:n,flag:a}:{encoding:n}).then(async c=>await new Promise(s=>{ke[o??"none"](c,(g,m)=>{s(g?void 0:r?m:m.toString());});})).catch(()=>{})},he=Se;var Oe={brotli:brotliDecompressSync,gzip:unzipSync,none:e=>e},Ee=(e,t)=>{let{buffer:r,compression:o,encoding:n,flag:a}=t??{};try{let c=readFileSync(e,a?{encoding:n,flag:a}:{encoding:n}),s=Oe[o??"none"](c);return r?s:s.toString()}catch{return}},Re=Ee;
|
|
7
8
|
|
|
8
|
-
export {
|
|
9
|
+
export { N as collect, H as collectSync, ie as findUp, le as findUpSync, me as isAccessible, ye as isAccessibleSync, he as readFile, Re as readFileSync, S as walk, h as walkSync };
|
|
9
10
|
//# sourceMappingURL=out.js.map
|
|
10
11
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.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","../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,OAAO,IAAIC,CAAQ,GAAG,CACrC,EAEOC,EAAQH,ECzBf,OAAS,iBAAAI,MAAqB,WAE9B,IAAMC,EAAUC,GAAqCA,aAAqB,IAAMF,EAAcE,CAAS,EAAIA,EAEpGC,EAAQF,ECJf,IAAMG,EAAc,CAACC,EAAcC,EAAuBC,EAAkBC,IACpEF,GAAc,CAACA,EAAW,KAAMG,GAAuBJ,EAAK,SAASI,CAAS,CAAC,GAI/EF,GAAS,CAACA,EAAM,KAAMG,GAAqBA,EAAQ,KAAKL,CAAI,CAAC,EACtD,GAGJ,EAAEG,GAAQA,EAAK,KAAME,GAAqBA,EAAQ,KAAKL,CAAI,CAAC,GAGhEM,EAAQP,EJIf,IAAMQ,EAAmB,MAA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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"]}
|
|
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","../src/read-file.ts","../src/read-file-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","nodeReadFile","brotliDecompress","unzip","decompressionMethods","buffer","callback","readFile","compression","encoding","flag","content","result","read_file_default","nodeReadFileSync","brotliDecompressSync","unzipSync","readFileSync","decompressed","read_file_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,G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AE,SAAAD,EAAU,KAAAC,CAAK,EAAI,CAAE,SAAAD,CAAS,CAAC,EACnE,KACG,MAAOE,GAEH,MAAM,IAAI,QAAqC5E,GAAY,CACvDqE,GAAqBI,GAAe,MAAM,EAAEG,EAAS,CAACzC,EAAO0C,IAAW,CAEhE7E,EADAmC,EACQ,OAECmC,EAASO,EAASA,EAAO,SAAS,CAF1B,CAIzB,CAAC,CACL,CAAC,CACT,EACC,MAAM,IAAG,EAAY,CAC9B,EAEOC,GAAQN,GCtCf,OAAS,gBAAgBO,OAAwB,UACjD,OAAS,wBAAAC,GAAsB,aAAAC,OAAiB,YAIhD,IAAMZ,GAAuB,CACzB,OAAQW,GACR,KAAMC,GACN,KAAOX,GAAmBA,CAC9B,EAEMY,GAAe,CACjBpE,EACAuB,IAC6B,CAC7B,GAAM,CAAE,OAAAiC,EAAQ,YAAAG,EAAa,SAAAC,EAAU,KAAAC,CAAK,EAAItC,GAAW,CAAC,EAE5D,GAAI,CAGA,IAAMuC,EAAUG,GAAiBjE,EAAM6D,EAAO,CAAE,SAAAD,EAAU,KAAAC,CAAK,EAAI,CAAE,SAAAD,CAAS,CAAC,EAEzES,EAAed,GAAqBI,GAAe,MAAM,EAAEG,CAAO,EAExE,OAAQN,EAASa,EAAeA,EAAa,SAAS,CAC1D,MAAQ,CACJ,MACJ,CACJ,EAEOC,GAAQF","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","import { readFile as nodeReadFile } from \"node:fs/promises\";\nimport { brotliDecompress, unzip } from \"node:zlib\";\n\nimport type { ContentType, ReadFileOptions } from \"./types\";\n\nconst decompressionMethods = {\n brotli: brotliDecompress,\n gzip: unzip,\n none: (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => {\n callback(null, buffer);\n },\n} as const;\n\nconst readFile = async <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: string,\n options?: O,\n): Promise<ContentType<O> | undefined> => {\n const { buffer, compression, encoding, flag } = options ?? {};\n\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n return await nodeReadFile(path, flag ? { encoding, flag } : { encoding })\n .then(\n async (content) =>\n // eslint-disable-next-line compat/compat\n await new Promise<ContentType<O> | undefined>((resolve) => {\n decompressionMethods[compression ?? \"none\"](content, (error, result) => {\n if (error) {\n resolve(undefined);\n } else {\n resolve((buffer ? result : result.toString()) as ContentType<O>);\n }\n });\n }),\n )\n .catch(() => undefined);\n};\n\nexport default readFile;\n","import { readFileSync as nodeReadFileSync } from \"node:fs\";\nimport { brotliDecompressSync, unzipSync } from \"node:zlib\";\n\nimport type { ContentType, ReadFileOptions } from \"./types\";\n\nconst decompressionMethods = {\n brotli: brotliDecompressSync,\n gzip: unzipSync,\n none: (buffer: Buffer) => buffer,\n} as const;\n\nconst readFileSync = <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(\n path: string,\n options?: O,\n): ContentType<O> | undefined => {\n const { buffer, compression, encoding, flag } = options ?? {};\n\n try {\n // @ts-expect-error - TS doesn't like our typed `encoding` option\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n const content = nodeReadFileSync(path, flag ? { encoding, flag } : { encoding });\n\n const decompressed = decompressionMethods[compression ?? \"none\"](content);\n\n return (buffer ? decompressed : decompressed.toString()) as ContentType<O>;\n } catch {\n return undefined;\n }\n};\n\nexport default readFileSync;\n"]}
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/fs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Human friendly file system utilities for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
7
|
+
"dir",
|
|
7
8
|
"directory",
|
|
8
9
|
"file",
|
|
10
|
+
"files",
|
|
11
|
+
"filesystem",
|
|
9
12
|
"find",
|
|
10
13
|
"find-up",
|
|
11
14
|
"findup",
|
|
12
15
|
"folder",
|
|
16
|
+
"fs",
|
|
17
|
+
"fs-safe",
|
|
13
18
|
"look",
|
|
14
19
|
"look-up",
|
|
15
20
|
"match",
|
|
@@ -17,15 +22,19 @@
|
|
|
17
22
|
"parent",
|
|
18
23
|
"parents",
|
|
19
24
|
"path",
|
|
20
|
-
"
|
|
25
|
+
"read",
|
|
26
|
+
"read-file",
|
|
21
27
|
"resolve",
|
|
28
|
+
"safe",
|
|
22
29
|
"search",
|
|
23
30
|
"up",
|
|
24
31
|
"visulima",
|
|
25
32
|
"walk",
|
|
26
33
|
"walking",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
34
|
+
"write",
|
|
35
|
+
"write-dir",
|
|
36
|
+
"write-file",
|
|
37
|
+
"write-safe"
|
|
29
38
|
],
|
|
30
39
|
"homepage": "https://www.visulima.com/docs/package/fs",
|
|
31
40
|
"repository": {
|