@visulima/fs 1.2.0 → 1.3.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.
@@ -0,0 +1,11 @@
1
+ declare class JSONError extends Error {
2
+ #private;
3
+ fileName: string | undefined;
4
+ codeFrame: string | undefined;
5
+ readonly name = "JSONError";
6
+ constructor(message: string);
7
+ get message(): string;
8
+ set message(message: string);
9
+ }
10
+
11
+ export { JSONError as J };
@@ -0,0 +1,60 @@
1
+ import { Dirent } from 'node:fs';
2
+
3
+ type ColorizeMethod = (value: string) => string;
4
+ interface WalkOptions {
5
+ extensions?: string[];
6
+ followSymlinks?: boolean;
7
+ includeDirs?: boolean;
8
+ includeFiles?: boolean;
9
+ includeSymlinks?: boolean;
10
+ match?: (RegExp | string)[];
11
+ maxDepth?: number;
12
+ skip?: (RegExp | string)[];
13
+ }
14
+ interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
15
+ path: string;
16
+ }
17
+ type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
18
+ type ReadFileOptions<C> = {
19
+ buffer?: boolean;
20
+ compression?: C;
21
+ encoding?: ReadFileEncoding | undefined;
22
+ flag?: number | string | undefined;
23
+ };
24
+ type ContentType<O = undefined> = O extends {
25
+ buffer: true;
26
+ } ? Buffer : string;
27
+ type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
28
+ type CodeFrameLocation = {
29
+ column?: number;
30
+ line: number;
31
+ };
32
+ type CodeFrameOptions = {
33
+ color?: {
34
+ gutter?: ColorizeMethod;
35
+ marker?: ColorizeMethod;
36
+ message?: ColorizeMethod;
37
+ };
38
+ };
39
+ type ReadJsonOptions = CodeFrameOptions & {
40
+ beforeParse?: (source: string) => string;
41
+ };
42
+ type WriteFileOptions = {
43
+ chown?: {
44
+ gid: number;
45
+ uid: number;
46
+ };
47
+ encoding?: BufferEncoding | null | undefined;
48
+ flag?: string | undefined;
49
+ mode?: number;
50
+ overwrite?: boolean;
51
+ recursive?: boolean;
52
+ };
53
+ type JsonReplacer = (this: unknown, key: string, value: unknown) => unknown;
54
+ type WriteJsonOptions = WriteFileOptions & {
55
+ detectIndent?: boolean;
56
+ indent?: number | string | undefined;
57
+ replacer?: (number | string)[] | JsonReplacer | null;
58
+ };
59
+
60
+ export type { ContentType as C, JsonReviver as J, ReadFileOptions as R, WalkOptions as W, ReadJsonOptions as a, WalkEntry as b, WriteFileOptions as c, WriteJsonOptions as d, CodeFrameLocation as e, JsonReplacer as f, ReadFileEncoding as g, CodeFrameOptions as h };
@@ -0,0 +1,60 @@
1
+ import { Dirent } from 'node:fs';
2
+
3
+ type ColorizeMethod = (value: string) => string;
4
+ interface WalkOptions {
5
+ extensions?: string[];
6
+ followSymlinks?: boolean;
7
+ includeDirs?: boolean;
8
+ includeFiles?: boolean;
9
+ includeSymlinks?: boolean;
10
+ match?: (RegExp | string)[];
11
+ maxDepth?: number;
12
+ skip?: (RegExp | string)[];
13
+ }
14
+ interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
15
+ path: string;
16
+ }
17
+ type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
18
+ type ReadFileOptions<C> = {
19
+ buffer?: boolean;
20
+ compression?: C;
21
+ encoding?: ReadFileEncoding | undefined;
22
+ flag?: number | string | undefined;
23
+ };
24
+ type ContentType<O = undefined> = O extends {
25
+ buffer: true;
26
+ } ? Buffer : string;
27
+ type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
28
+ type CodeFrameLocation = {
29
+ column?: number;
30
+ line: number;
31
+ };
32
+ type CodeFrameOptions = {
33
+ color?: {
34
+ gutter?: ColorizeMethod;
35
+ marker?: ColorizeMethod;
36
+ message?: ColorizeMethod;
37
+ };
38
+ };
39
+ type ReadJsonOptions = CodeFrameOptions & {
40
+ beforeParse?: (source: string) => string;
41
+ };
42
+ type WriteFileOptions = {
43
+ chown?: {
44
+ gid: number;
45
+ uid: number;
46
+ };
47
+ encoding?: BufferEncoding | null | undefined;
48
+ flag?: string | undefined;
49
+ mode?: number;
50
+ overwrite?: boolean;
51
+ recursive?: boolean;
52
+ };
53
+ type JsonReplacer = (this: unknown, key: string, value: unknown) => unknown;
54
+ type WriteJsonOptions = WriteFileOptions & {
55
+ detectIndent?: boolean;
56
+ indent?: number | string | undefined;
57
+ replacer?: (number | string)[] | JsonReplacer | null;
58
+ };
59
+
60
+ export type { ContentType as C, JsonReviver as J, ReadFileOptions as R, WalkOptions as W, ReadJsonOptions as a, WalkEntry as b, WriteFileOptions as c, WriteJsonOptions as d, CodeFrameLocation as e, JsonReplacer as f, ReadFileEncoding as g, CodeFrameOptions as h };
package/dist/utils.cjs ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var chunkC4ULY5SU_cjs = require('./chunk-C4ULY5SU.cjs');
4
+ var chunkN5NZURYL_cjs = require('./chunk-N5NZURYL.cjs');
5
+
6
+ var p=(e,{whitespace:t=!0}={})=>e.replace(f,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:t?r.replaceAll(/\S/g," "):""),f=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,l=p;
7
+
8
+ Object.defineProperty(exports, 'parseJson', {
9
+ enumerable: true,
10
+ get: function () { return chunkC4ULY5SU_cjs.a; }
11
+ });
12
+ Object.defineProperty(exports, 'JSONError', {
13
+ enumerable: true,
14
+ get: function () { return chunkN5NZURYL_cjs.a; }
15
+ });
16
+ exports.stripJsonComments = l;
17
+ //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/strip-json-comments.ts"],"names":["stripJsonComments","jsonString","whitespace","INTERNAL_STRIP_JSON_REGEX","match","strip_json_comments_default"],"mappings":"kFAEA,IAAMA,EAAoB,CAACC,EAAoB,CAAE,WAAAC,EAAa,EAAK,EAAI,CAAC,IASpED,EAAW,QAAQE,EAA4BC,GAEvCA,EAAM,WAAW,GAAG,GAAMA,EAAM,CAAC,IAAM,KAAO,CAACA,EAAM,SAAS,IAAI,EAC3DA,EAIJF,EAAaE,EAAM,WAAW,MAAO,GAAG,EAAI,EACtD,EAEQD,EAA4B,iEAElCE,EAAQL","sourcesContent":["// Copyright by https://github.com/swansontec\n\nconst stripJsonComments = (jsonString: string, { whitespace = true } = {}): string =>\n // This regular expression translates to:\n //\n // /quoted-string|line-comment|block-comment/g\n //\n // This means that comment characters inside of strings will match\n // as strings, not comments, so we can just skip the whole string\n // in the replacer function.\n // eslint-disable-next-line unicorn/prefer-string-replace-all,@typescript-eslint/no-use-before-define\n jsonString.replace(INTERNAL_STRIP_JSON_REGEX, (match) => {\n // Skip strings & broken block comments:\n if (match.startsWith('\"') || (match[1] === \"*\" && !match.endsWith(\"*/\"))) {\n return match;\n }\n\n // Replace comments with whitespace (or not):\n return whitespace ? match.replaceAll(/\\S/g, \" \") : \"\";\n });\n\nexport const INTERNAL_STRIP_JSON_REGEX = /\"(?:[^\"\\\\]|\\\\.)*\"?|\\/\\/[^\\r\\n]*|\\/\\*(?:[^*]|\\*[^/])*(?:\\*\\/)?/g;\n\nexport default stripJsonComments;\n"]}
@@ -0,0 +1,13 @@
1
+ export { J as JSONError } from './json-error-UVjLdb7z.cjs';
2
+ import { JsonValue } from 'type-fest';
3
+ import { h as CodeFrameOptions, J as JsonReviver } from './types-4y_sJiOD.cjs';
4
+ import 'node:fs';
5
+
6
+ declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
7
+ declare function parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;
8
+
9
+ declare const stripJsonComments: (jsonString: string, { whitespace }?: {
10
+ whitespace?: boolean | undefined;
11
+ }) => string;
12
+
13
+ export { parseJson, stripJsonComments };
@@ -0,0 +1,13 @@
1
+ export { J as JSONError } from './json-error-UVjLdb7z.js';
2
+ import { JsonValue } from 'type-fest';
3
+ import { h as CodeFrameOptions, J as JsonReviver } from './types-4y_sJiOD.js';
4
+ import 'node:fs';
5
+
6
+ declare function parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;
7
+ declare function parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;
8
+
9
+ declare const stripJsonComments: (jsonString: string, { whitespace }?: {
10
+ whitespace?: boolean | undefined;
11
+ }) => string;
12
+
13
+ export { parseJson, stripJsonComments };
package/dist/utils.js ADDED
@@ -0,0 +1,8 @@
1
+ export { a as parseJson } from './chunk-7UNFLLNN.js';
2
+ export { a as JSONError } from './chunk-UPN3Y5W3.js';
3
+
4
+ var f=(e,{whitespace:t=!0}={})=>e.replace(l,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:t?r.replaceAll(/\S/g," "):""),l=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,a=f;
5
+
6
+ export { a as stripJsonComments };
7
+ //# sourceMappingURL=out.js.map
8
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/strip-json-comments.ts"],"names":["stripJsonComments","jsonString","whitespace","INTERNAL_STRIP_JSON_REGEX","match","strip_json_comments_default"],"mappings":"gFAEA,IAAMA,EAAoB,CAACC,EAAoB,CAAE,WAAAC,EAAa,EAAK,EAAI,CAAC,IASpED,EAAW,QAAQE,EAA4BC,GAEvCA,EAAM,WAAW,GAAG,GAAMA,EAAM,CAAC,IAAM,KAAO,CAACA,EAAM,SAAS,IAAI,EAC3DA,EAIJF,EAAaE,EAAM,WAAW,MAAO,GAAG,EAAI,EACtD,EAEQD,EAA4B,iEAElCE,EAAQL","sourcesContent":["// Copyright by https://github.com/swansontec\n\nconst stripJsonComments = (jsonString: string, { whitespace = true } = {}): string =>\n // This regular expression translates to:\n //\n // /quoted-string|line-comment|block-comment/g\n //\n // This means that comment characters inside of strings will match\n // as strings, not comments, so we can just skip the whole string\n // in the replacer function.\n // eslint-disable-next-line unicorn/prefer-string-replace-all,@typescript-eslint/no-use-before-define\n jsonString.replace(INTERNAL_STRIP_JSON_REGEX, (match) => {\n // Skip strings & broken block comments:\n if (match.startsWith('\"') || (match[1] === \"*\" && !match.endsWith(\"*/\"))) {\n return match;\n }\n\n // Replace comments with whitespace (or not):\n return whitespace ? match.replaceAll(/\\S/g, \" \") : \"\";\n });\n\nexport const INTERNAL_STRIP_JSON_REGEX = /\"(?:[^\"\\\\]|\\\\.)*\"?|\\/\\/[^\\r\\n]*|\\/\\*(?:[^*]|\\*[^/])*(?:\\*\\/)?/g;\n\nexport default stripJsonComments;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/fs",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Human friendly file system utilities for Node.js",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -17,6 +17,8 @@
17
17
  "fs-safe",
18
18
  "look",
19
19
  "look-up",
20
+ "json",
21
+ "read-json",
20
22
  "match",
21
23
  "package",
22
24
  "parent",
@@ -58,22 +60,42 @@
58
60
  "email": "d.bannert@anolilab.de"
59
61
  },
60
62
  "sideEffects": false,
63
+ "type": "module",
61
64
  "exports": {
62
65
  ".": {
63
66
  "require": {
67
+ "types": "./dist/index.d.cts",
68
+ "default": "./dist/index.cjs"
69
+ },
70
+ "import": {
64
71
  "types": "./dist/index.d.ts",
65
72
  "default": "./dist/index.js"
73
+ }
74
+ },
75
+ "./utils": {
76
+ "require": {
77
+ "types": "./dist/utils.d.cts",
78
+ "default": "./dist/utils.cjs"
79
+ },
80
+ "import": {
81
+ "types": "./dist/utils.d.ts",
82
+ "default": "./dist/utils.js"
83
+ }
84
+ },
85
+ "./error": {
86
+ "require": {
87
+ "types": "./dist/error.d.cts",
88
+ "default": "./dist/error.cjs"
66
89
  },
67
90
  "import": {
68
- "types": "./dist/index.d.mts",
69
- "default": "./dist/index.mjs"
91
+ "types": "./dist/error.d.ts",
92
+ "default": "./dist/error.js"
70
93
  }
71
94
  },
72
95
  "./package.json": "./package.json"
73
96
  },
74
- "main": "dist/index.js",
75
- "module": "dist/index.mjs",
76
- "source": "src/index.ts",
97
+ "main": "dist/index.cjs",
98
+ "module": "dist/index.js",
77
99
  "types": "dist/index.d.ts",
78
100
  "files": [
79
101
  "dist/**",
@@ -86,25 +108,29 @@
86
108
  "build:prod": "cross-env NODE_ENV=production tsup",
87
109
  "clean": "rimraf node_modules dist .eslintcache",
88
110
  "dev": "pnpm run build --watch",
89
- "lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js",
90
- "lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js --fix",
111
+ "lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
112
+ "lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix",
91
113
  "lint:packagejson": "publint --strict",
92
- "lint:prettier": "prettier --config=.prettierrc.js --check .",
93
- "lint:prettier:fix": "prettier --config=.prettierrc.js --write .",
114
+ "lint:prettier": "prettier --config=.prettierrc.cjs --check .",
115
+ "lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
94
116
  "lint:types": "tsc --noEmit",
95
117
  "test": "vitest run",
96
118
  "test:coverage": "vitest run --coverage",
97
119
  "test:ui": "vitest --ui --coverage.enabled=true",
98
120
  "test:watch": "vitest"
99
121
  },
122
+ "dependencies": {
123
+ "type-fest": "^4.12.0"
124
+ },
100
125
  "devDependencies": {
126
+ "detect-indent": "^7.0.1",
101
127
  "@anolilab/eslint-config": "^15.0.3",
102
128
  "@anolilab/prettier-config": "^5.0.14",
103
129
  "@anolilab/semantic-release-preset": "^8.0.3",
104
130
  "@babel/core": "^7.24.0",
105
131
  "@rushstack/eslint-plugin-security": "^0.8.1",
106
- "@types/micromatch": "^4.0.6",
107
132
  "@types/node": "18.18.14",
133
+ "@visulima/error": "3.2.0",
108
134
  "@vitest/coverage-v8": "^1.3.1",
109
135
  "@vitest/ui": "^1.3.1",
110
136
  "cross-env": "^7.0.3",
@@ -113,10 +139,12 @@
113
139
  "eslint-plugin-etc": "^2.0.3",
114
140
  "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
115
141
  "eslint-plugin-mdx": "^3.1.5",
116
- "eslint-plugin-vitest": "^0.3.22",
142
+ "eslint-plugin-vitest": "^0.3.25",
117
143
  "eslint-plugin-vitest-globals": "^1.4.0",
118
144
  "prettier": "^3.2.5",
145
+ "redos-detector": "^5.1.0",
119
146
  "rimraf": "^5.0.5",
147
+ "safe-regex2": "^3.1.0",
120
148
  "semantic-release": "^23.0.2",
121
149
  "sort-package-json": "^2.8.0",
122
150
  "tempy": "^3.1.0",
@@ -142,5 +170,10 @@
142
170
  "info_on_disabling_jsonc_sort_keys_rule": false,
143
171
  "info_on_disabling_etc_no_deprecated": false
144
172
  }
145
- }
173
+ },
174
+ "sources": [
175
+ "src/index.ts",
176
+ "src/error.ts",
177
+ "src/utils.ts"
178
+ ]
146
179
  }
package/dist/index.d.mts DELETED
@@ -1,56 +0,0 @@
1
- import { Dirent } from 'node:fs';
2
-
3
- interface WalkOptions {
4
- extensions?: string[];
5
- followSymlinks?: boolean;
6
- includeDirs?: boolean;
7
- includeFiles?: boolean;
8
- includeSymlinks?: boolean;
9
- match?: (RegExp | string)[];
10
- maxDepth?: number;
11
- skip?: (RegExp | string)[];
12
- }
13
- interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
14
- path: string;
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;
25
-
26
- declare const collect: (directory: string, options?: WalkOptions) => Promise<string[]>;
27
-
28
- declare const collectSync: (directory: string, options?: WalkOptions) => string[];
29
-
30
- declare const findUp: (name: string, options?: {
31
- cwd?: URL | string;
32
- stopAt?: URL | string;
33
- type?: "directory" | "file";
34
- }) => Promise<string | undefined>;
35
-
36
- declare const findUpSync: (name: string, options?: {
37
- cwd?: URL | string;
38
- stopAt?: URL | string;
39
- type?: "directory" | "file";
40
- }) => string | undefined;
41
-
42
- declare function isAccessible(path: string, mode?: number): Promise<boolean>;
43
- declare function isAccessible(path: string[], mode?: number): Promise<boolean[]>;
44
-
45
- declare function isAccessibleSync(path: string, mode?: number): boolean;
46
- declare function isAccessibleSync(path: string[], mode?: number): boolean[];
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
-
52
- declare function walk(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): AsyncIterableIterator<WalkEntry>;
53
-
54
- declare function walkSync(directory: URL | string, { extensions, followSymlinks, includeDirs: includeDirectories, includeFiles, includeSymlinks, match, maxDepth, skip, }?: WalkOptions): IterableIterator<WalkEntry>;
55
-
56
- export { type WalkEntry, type WalkOptions, collect, collectSync, findUp, findUpSync, isAccessible, isAccessibleSync, readFile, readFileSync, walk, walkSync };
package/dist/index.mjs DELETED
@@ -1,11 +0,0 @@
1
- import { readdir, realpath, stat, access, readFile } from 'node:fs/promises';
2
- import { resolve, join, normalize, basename, parse, isAbsolute, dirname } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { readdirSync, realpathSync, statSync, accessSync, readFileSync } from 'node:fs';
5
- import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
6
-
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;
8
-
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 };
10
- //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
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,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,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C,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"]}