@willbooster/shared-lib-node 6.1.0 → 6.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/glob.cjs +1 -1
- package/dist/glob.cjs.map +1 -1
- package/dist/glob.d.ts +25 -2
- package/dist/glob.js +1 -1
- package/dist/glob.js.map +1 -1
- package/package.json +1 -1
package/dist/glob.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("node:fs"),s=require("node:path");function n(e,n){
|
|
1
|
+
"use strict";var e=require("node:fs"),s=require("node:path");function n(e,n){if(!n)return!1;const i=s.join(e.parentPath,e.name).replaceAll("\\","/");return n.some((e=>e.test(i)))}exports.glob=async function*(i,l){if(process.versions.bun){const e=new(require(String("bun")).Glob)(i);for await(const i of e.scan({cwd:l.cwd,onlyFiles:l.onlyFiles})){const e=s.parse(i),o={name:e.base,parentPath:s.resolve(l.cwd??".",e.dir)};n(o,l.excludes)||(yield o)}}else for await(const s of e.promises.glob(i,{...l,exclude:l.excludes?.length?e=>n(e,l.excludes):void 0,withFileTypes:!0}))l.onlyFiles&&!s.isFile()||s.isFile()&&n(s,l.excludes)||(yield s)},exports.globSync=function(i,l){if(process.versions.bun){const e=new(require(String("bun")).Glob)(i),o=[];for(const i of e.scanSync({cwd:l.cwd,onlyFiles:l.onlyFiles})){const e=s.parse(i),r={name:e.base,parentPath:s.resolve(l.cwd??".",e.dir)};n(r,l.excludes)||o.push(r)}return o}return e.globSync(i,{...l,exclude:l.excludes?e=>n(e,l.excludes):void 0,withFileTypes:!0}).filter((e=>!(l.onlyFiles&&!e.isFile()||e.isFile()&&n(e,l.excludes))))};
|
|
2
2
|
//# sourceMappingURL=glob.cjs.map
|
package/dist/glob.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.cjs","sources":["../src/glob.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { Glob } from 'bun';\n\ntype NodeJsDirentLike = {\n name: string;\n parentPath: string;\n};\n\nexport async function* glob(\n pattern: string,\n options: { cwd?: string; excludes?:
|
|
1
|
+
{"version":3,"file":"glob.cjs","sources":["../src/glob.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { Glob } from 'bun';\n\n/**\n * Represents a file system entry with name and parent path information.\n */\ntype NodeJsDirentLike = {\n /** The name of the file or directory */\n name: string;\n /** The absolute path to the parent directory */\n parentPath: string;\n};\n\n/**\n * Asynchronously glob for files and directories.\n * @param pattern - The glob pattern to match files and directories\n * @param options - Configuration options for globbing\n * @param options.cwd - The working directory to start globbing from\n * @param options.excludes - Regular expressions to exclude from the results\n * @param options.onlyFiles - If true, only return files (not directories)\n * @returns An async iterator of matching files and directories\n */\nexport async function* glob(\n pattern: string,\n options: { cwd?: string; excludes?: RegExp[]; onlyFiles: boolean }\n): NodeJS.AsyncIterator<NodeJsDirentLike> {\n // cf. https://bun.sh/guides/util/detect-bun\n if (process.versions.bun) {\n // Use require & String to avoid loading bun on Next.js\n // eslint-disable-next-line @typescript-eslint/no-require-imports,unicorn/prefer-module\n const bun = require(String('bun'));\n const bunGlob = new bun.Glob(pattern) as Glob;\n for await (const direntPath of bunGlob.scan({ cwd: options.cwd, onlyFiles: options.onlyFiles })) {\n const parsedDirentPath = path.parse(direntPath);\n const dirent = {\n name: parsedDirentPath.base,\n parentPath: path.resolve(options.cwd ?? '.', parsedDirentPath.dir),\n };\n if (isExcluded(dirent, options.excludes)) continue;\n\n yield dirent;\n }\n } else {\n for await (const dirent of fs.promises.glob(pattern, {\n ...options,\n exclude: options.excludes?.length ? (dirent) => isExcluded(dirent, options.excludes) : undefined,\n withFileTypes: true,\n })) {\n if (options.onlyFiles && !dirent.isFile()) continue;\n // We need double-check here because files are ignored by `exclude` option.\n if (dirent.isFile() && isExcluded(dirent, options.excludes)) continue;\n\n yield dirent;\n }\n }\n}\n\n/**\n * Synchronously glob for files and directories.\n * @param pattern - The glob pattern to match files and directories\n * @param options - Configuration options for globbing\n * @param options.cwd - The working directory to start globbing from\n * @param options.excludes - Regular expressions to exclude from the results\n * @param options.onlyFiles - If true, only return files (not directories)\n * @returns An array of matching files and directories\n */\nexport function globSync(\n pattern: string,\n options: { cwd?: string; excludes?: RegExp[]; onlyFiles: boolean }\n): NodeJsDirentLike[] {\n // cf. https://bun.sh/guides/util/detect-bun\n if (process.versions.bun) {\n // Use require & String to avoid loading bun on Next.js\n // eslint-disable-next-line @typescript-eslint/no-require-imports,unicorn/prefer-module\n const bun = require(String('bun'));\n const bunGlob = new bun.Glob(pattern) as Glob;\n const dirents: NodeJsDirentLike[] = [];\n for (const direntPath of bunGlob.scanSync({ cwd: options.cwd, onlyFiles: options.onlyFiles })) {\n const parsedDirentPath = path.parse(direntPath);\n const dirent = {\n name: parsedDirentPath.base,\n parentPath: path.resolve(options.cwd ?? '.', parsedDirentPath.dir),\n };\n if (isExcluded(dirent, options.excludes)) continue;\n\n dirents.push(dirent);\n }\n return dirents;\n } else {\n return (\n fs\n .globSync(pattern, {\n ...options,\n exclude: options.excludes ? (dirent) => isExcluded(dirent, options.excludes) : undefined,\n withFileTypes: true,\n })\n // We need double-check here because files are ignored by `exclude` option.\n .filter(\n (dirent) =>\n !(options.onlyFiles && !dirent.isFile()) && !(dirent.isFile() && isExcluded(dirent, options.excludes))\n )\n );\n }\n}\n\nfunction isExcluded(dirent: NodeJsDirentLike, excludes?: RegExp[]): boolean {\n if (!excludes) return false;\n\n const targetPath = path.join(dirent.parentPath, dirent.name).replaceAll('\\\\', '/');\n return excludes.some((pattern) => pattern.test(targetPath));\n}\n"],"names":["isExcluded","dirent","excludes","targetPath","path","join","parentPath","name","replaceAll","some","pattern","test","async","options","process","versions","bun","bunGlob","require","String","Glob","direntPath","scan","cwd","onlyFiles","parsedDirentPath","parse","base","resolve","dir","fs","promises","glob","exclude","length","undefined","withFileTypes","isFile","dirents","scanSync","push","globSync","filter"],"mappings":"6DA2GA,SA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qC,CACT,CACE,OACER,EACGW,SAAS/B,EAAS,IACdG,EACHoB,QAASpB,EAAQX,SAAYD,GAAWD,EAAWC,EAAQY,EAAQX,eAAYiC,EAC/EC,eAAe,IAGhBM,QACEzC,KACGY,EAAQW,YAAcvB,EAAOoC,UAAepC,EAAOoC,UAAYrC,EAAWC,EAAQY,EAAQX,YAIxG"}
|
package/dist/glob.d.ts
CHANGED
|
@@ -1,15 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a file system entry with name and parent path information.
|
|
3
|
+
*/
|
|
1
4
|
type NodeJsDirentLike = {
|
|
5
|
+
/** The name of the file or directory */
|
|
2
6
|
name: string;
|
|
7
|
+
/** The absolute path to the parent directory */
|
|
3
8
|
parentPath: string;
|
|
4
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Asynchronously glob for files and directories.
|
|
12
|
+
* @param pattern - The glob pattern to match files and directories
|
|
13
|
+
* @param options - Configuration options for globbing
|
|
14
|
+
* @param options.cwd - The working directory to start globbing from
|
|
15
|
+
* @param options.excludes - Regular expressions to exclude from the results
|
|
16
|
+
* @param options.onlyFiles - If true, only return files (not directories)
|
|
17
|
+
* @returns An async iterator of matching files and directories
|
|
18
|
+
*/
|
|
5
19
|
export declare function glob(pattern: string, options: {
|
|
6
20
|
cwd?: string;
|
|
7
|
-
excludes?:
|
|
21
|
+
excludes?: RegExp[];
|
|
8
22
|
onlyFiles: boolean;
|
|
9
23
|
}): NodeJS.AsyncIterator<NodeJsDirentLike>;
|
|
24
|
+
/**
|
|
25
|
+
* Synchronously glob for files and directories.
|
|
26
|
+
* @param pattern - The glob pattern to match files and directories
|
|
27
|
+
* @param options - Configuration options for globbing
|
|
28
|
+
* @param options.cwd - The working directory to start globbing from
|
|
29
|
+
* @param options.excludes - Regular expressions to exclude from the results
|
|
30
|
+
* @param options.onlyFiles - If true, only return files (not directories)
|
|
31
|
+
* @returns An array of matching files and directories
|
|
32
|
+
*/
|
|
10
33
|
export declare function globSync(pattern: string, options: {
|
|
11
34
|
cwd?: string;
|
|
12
|
-
excludes?:
|
|
35
|
+
excludes?: RegExp[];
|
|
13
36
|
onlyFiles: boolean;
|
|
14
37
|
}): NodeJsDirentLike[];
|
|
15
38
|
export {};
|
package/dist/glob.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:fs";import
|
|
1
|
+
import e from"node:fs";import s from"node:path";async function*n(n,o){if(process.versions.bun){const e=new(require(String("bun")).Glob)(n);for await(const n of e.scan({cwd:o.cwd,onlyFiles:o.onlyFiles})){const e=s.parse(n),l={name:e.base,parentPath:s.resolve(o.cwd??".",e.dir)};i(l,o.excludes)||(yield l)}}else for await(const s of e.promises.glob(n,{...o,exclude:o.excludes?.length?e=>i(e,o.excludes):void 0,withFileTypes:!0}))o.onlyFiles&&!s.isFile()||s.isFile()&&i(s,o.excludes)||(yield s)}function o(n,o){if(process.versions.bun){const e=new(require(String("bun")).Glob)(n),l=[];for(const n of e.scanSync({cwd:o.cwd,onlyFiles:o.onlyFiles})){const e=s.parse(n),r={name:e.base,parentPath:s.resolve(o.cwd??".",e.dir)};i(r,o.excludes)||l.push(r)}return l}return e.globSync(n,{...o,exclude:o.excludes?e=>i(e,o.excludes):void 0,withFileTypes:!0}).filter((e=>!(o.onlyFiles&&!e.isFile()||e.isFile()&&i(e,o.excludes))))}function i(e,n){if(!n)return!1;const o=s.join(e.parentPath,e.name).replaceAll("\\","/");return n.some((e=>e.test(o)))}export{n as glob,o as globSync};
|
|
2
2
|
//# sourceMappingURL=glob.js.map
|
package/dist/glob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.js","sources":["../src/glob.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { Glob } from 'bun';\n\ntype NodeJsDirentLike = {\n name: string;\n parentPath: string;\n};\n\nexport async function* glob(\n pattern: string,\n options: { cwd?: string; excludes?:
|
|
1
|
+
{"version":3,"file":"glob.js","sources":["../src/glob.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { Glob } from 'bun';\n\n/**\n * Represents a file system entry with name and parent path information.\n */\ntype NodeJsDirentLike = {\n /** The name of the file or directory */\n name: string;\n /** The absolute path to the parent directory */\n parentPath: string;\n};\n\n/**\n * Asynchronously glob for files and directories.\n * @param pattern - The glob pattern to match files and directories\n * @param options - Configuration options for globbing\n * @param options.cwd - The working directory to start globbing from\n * @param options.excludes - Regular expressions to exclude from the results\n * @param options.onlyFiles - If true, only return files (not directories)\n * @returns An async iterator of matching files and directories\n */\nexport async function* glob(\n pattern: string,\n options: { cwd?: string; excludes?: RegExp[]; onlyFiles: boolean }\n): NodeJS.AsyncIterator<NodeJsDirentLike> {\n // cf. https://bun.sh/guides/util/detect-bun\n if (process.versions.bun) {\n // Use require & String to avoid loading bun on Next.js\n // eslint-disable-next-line @typescript-eslint/no-require-imports,unicorn/prefer-module\n const bun = require(String('bun'));\n const bunGlob = new bun.Glob(pattern) as Glob;\n for await (const direntPath of bunGlob.scan({ cwd: options.cwd, onlyFiles: options.onlyFiles })) {\n const parsedDirentPath = path.parse(direntPath);\n const dirent = {\n name: parsedDirentPath.base,\n parentPath: path.resolve(options.cwd ?? '.', parsedDirentPath.dir),\n };\n if (isExcluded(dirent, options.excludes)) continue;\n\n yield dirent;\n }\n } else {\n for await (const dirent of fs.promises.glob(pattern, {\n ...options,\n exclude: options.excludes?.length ? (dirent) => isExcluded(dirent, options.excludes) : undefined,\n withFileTypes: true,\n })) {\n if (options.onlyFiles && !dirent.isFile()) continue;\n // We need double-check here because files are ignored by `exclude` option.\n if (dirent.isFile() && isExcluded(dirent, options.excludes)) continue;\n\n yield dirent;\n }\n }\n}\n\n/**\n * Synchronously glob for files and directories.\n * @param pattern - The glob pattern to match files and directories\n * @param options - Configuration options for globbing\n * @param options.cwd - The working directory to start globbing from\n * @param options.excludes - Regular expressions to exclude from the results\n * @param options.onlyFiles - If true, only return files (not directories)\n * @returns An array of matching files and directories\n */\nexport function globSync(\n pattern: string,\n options: { cwd?: string; excludes?: RegExp[]; onlyFiles: boolean }\n): NodeJsDirentLike[] {\n // cf. https://bun.sh/guides/util/detect-bun\n if (process.versions.bun) {\n // Use require & String to avoid loading bun on Next.js\n // eslint-disable-next-line @typescript-eslint/no-require-imports,unicorn/prefer-module\n const bun = require(String('bun'));\n const bunGlob = new bun.Glob(pattern) as Glob;\n const dirents: NodeJsDirentLike[] = [];\n for (const direntPath of bunGlob.scanSync({ cwd: options.cwd, onlyFiles: options.onlyFiles })) {\n const parsedDirentPath = path.parse(direntPath);\n const dirent = {\n name: parsedDirentPath.base,\n parentPath: path.resolve(options.cwd ?? '.', parsedDirentPath.dir),\n };\n if (isExcluded(dirent, options.excludes)) continue;\n\n dirents.push(dirent);\n }\n return dirents;\n } else {\n return (\n fs\n .globSync(pattern, {\n ...options,\n exclude: options.excludes ? (dirent) => isExcluded(dirent, options.excludes) : undefined,\n withFileTypes: true,\n })\n // We need double-check here because files are ignored by `exclude` option.\n .filter(\n (dirent) =>\n !(options.onlyFiles && !dirent.isFile()) && !(dirent.isFile() && isExcluded(dirent, options.excludes))\n )\n );\n }\n}\n\nfunction isExcluded(dirent: NodeJsDirentLike, excludes?: RegExp[]): boolean {\n if (!excludes) return false;\n\n const targetPath = path.join(dirent.parentPath, dirent.name).replaceAll('\\\\', '/');\n return excludes.some((pattern) => pattern.test(targetPath));\n}\n"],"names":["async","glob","pattern","options","process","versions","bun","bunGlob","require","String","Glob","direntPath","scan","cwd","onlyFiles","parsedDirentPath","path","parse","dirent","name","base","parentPath","resolve","dir","isExcluded","excludes","fs","promises","exclude","length","undefined","withFileTypes","isFile","globSync","dirents","scanSync","push","filter","targetPath","join","replaceAll","some","test"],"mappings":"gDAwBOA,eAAgBC,EACrBC,EACAC,GAGA,GAAIC,QAAQC,SAASC,IAAK,CAGxB,MACMC,EAAU,IADJC,QAAQC,OAAO,QACHC,MAAKR,GAC7B,UAAW,MAAMS,KAAcJ,E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