diff --git a/@types/unmatch.d.ts b/@types/unmatch.d.ts new file mode 100644 index 0000000..064c382 --- /dev/null +++ b/@types/unmatch.d.ts @@ -0,0 +1,11 @@ +declare module 'unmatch' { + import picomatch = require('picomatch'); + + const unmatch: typeof picomatch & { + constants: typeof picomatch.constants & { + UNIGNORE: unique symbol; + } + }; + + export = unmatch; +} diff --git a/package.json b/package.json index 82a9172..99342e9 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "homepage": "https://github.com/SuperchupuDev/tinyglobby#readme", "dependencies": { "fdir": "^6.4.2", - "picomatch": "^4.0.2" + "unmatch": "^1.0.0" }, "devDependencies": { "@biomejs/biome": "^1.9.4", @@ -59,10 +59,5 @@ "access": "public", "provenance": true }, - "packageManager": "pnpm@9.13.2", - "pnpm": { - "patchedDependencies": { - "picomatch@4.0.2": "patches/picomatch@4.0.2.patch" - } - } + "packageManager": "pnpm@9.13.2" } diff --git a/patches/picomatch@4.0.2.patch b/patches/picomatch@4.0.2.patch deleted file mode 100644 index 4b3cb91..0000000 --- a/patches/picomatch@4.0.2.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/lib/picomatch.js b/lib/picomatch.js -index d0ebd9f163cf240a00998dec9ed69523d1405b4d..b5d9fb5b0f55b70f99a5012b80e91974b46699eb 100644 ---- a/lib/picomatch.js -+++ b/lib/picomatch.js -@@ -75,12 +75,17 @@ const picomatch = (glob, options, returnState = false) => { - return returnObject ? result : false; - } - -- if (isIgnored(input)) { -- if (typeof opts.onIgnore === 'function') { -- opts.onIgnore(result); -+ ignored: { -+ if (isIgnored(input)) { -+ if (typeof opts.onIgnore === 'function') { -+ if (opts.onIgnore(result) === true) { -+ result.isMatch = true; -+ break ignored; -+ } -+ } -+ result.isMatch = false; -+ return returnObject ? result : false; - } -- result.isMatch = false; -- return returnObject ? result : false; - } - - if (typeof opts.onMatch === 'function') { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 154e1db..701caee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,21 +4,16 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -patchedDependencies: - picomatch@4.0.2: - hash: uwrylfsjnx37nmis4n6nyhyebu - path: patches/picomatch@4.0.2.patch - importers: .: dependencies: fdir: specifier: ^6.4.2 - version: 6.4.2(picomatch@4.0.2(patch_hash=uwrylfsjnx37nmis4n6nyhyebu)) - picomatch: - specifier: ^4.0.2 - version: 4.0.2(patch_hash=uwrylfsjnx37nmis4n6nyhyebu) + version: 6.4.2(picomatch@4.0.2) + unmatch: + specifier: ^1.0.0 + version: 1.0.0 devDependencies: '@biomejs/biome': specifier: ^1.9.4 @@ -663,6 +658,10 @@ packages: undici-types@6.19.8: resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + unmatch@1.0.0: + resolution: {integrity: sha512-ZUMx4QEuvZC6nx4g8lKC77AakV6yBaIBMXBCRm1rIrEho+3+qx5pIXbu00AaHVPw2Vd4V9OLqDN8DkunC5y92Q==} + engines: {node: '>=12'} + webidl-conversions@4.0.2: resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} @@ -964,9 +963,9 @@ snapshots: '@esbuild/win32-ia32': 0.24.0 '@esbuild/win32-x64': 0.24.0 - fdir@6.4.2(picomatch@4.0.2(patch_hash=uwrylfsjnx37nmis4n6nyhyebu)): + fdir@6.4.2(picomatch@4.0.2): optionalDependencies: - picomatch: 4.0.2(patch_hash=uwrylfsjnx37nmis4n6nyhyebu) + picomatch: 4.0.2 foreground-child@3.3.0: dependencies: @@ -1036,7 +1035,7 @@ snapshots: picocolors@1.1.1: {} - picomatch@4.0.2(patch_hash=uwrylfsjnx37nmis4n6nyhyebu): {} + picomatch@4.0.2: {} pirates@4.0.6: {} @@ -1128,8 +1127,8 @@ snapshots: tinyglobby@0.2.10: dependencies: - fdir: 6.4.2(picomatch@4.0.2(patch_hash=uwrylfsjnx37nmis4n6nyhyebu)) - picomatch: 4.0.2(patch_hash=uwrylfsjnx37nmis4n6nyhyebu) + fdir: 6.4.2(picomatch@4.0.2) + picomatch: 4.0.2 tr46@1.0.1: dependencies: @@ -1169,6 +1168,8 @@ snapshots: undici-types@6.19.8: {} + unmatch@1.0.0: {} + webidl-conversions@4.0.2: {} whatwg-url@7.1.0: diff --git a/src/index.ts b/src/index.ts index 94fff29..bbf643f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import path, { posix } from 'node:path'; import { type Options as FdirOptions, fdir } from 'fdir'; -import picomatch from 'picomatch'; +import unmatch from 'unmatch'; import { isDynamicPattern } from './utils.ts'; export interface GlobOptions { @@ -177,21 +177,21 @@ function crawl(options: GlobOptions, cwd: string, sync: boolean) { const processed = processPatterns(options, cwd, properties); - const unignoreMatcher = processed.unignore.length === 0 ? undefined : picomatch(processed.unignore) + const unignoreMatcher = processed.unignore.length === 0 ? undefined : unmatch(processed.unignore) - const matcher = picomatch(processed.match, { + const matcher = unmatch(processed.match, { dot: options.dot, nocase: options.caseSensitiveMatch === false, ignore: processed.ignore, - onIgnore: unignoreMatcher ? (result => unignoreMatcher(result.output)) : undefined + onIgnore: unignoreMatcher ? (result => unignoreMatcher(result.output) && unmatch.constants.UNIGNORE) : undefined }); - const ignore = picomatch(processed.ignore, { + const ignore = unmatch(processed.ignore, { dot: options.dot, nocase: options.caseSensitiveMatch === false }); - const exclude = picomatch('*(../)**', { + const exclude = unmatch('*(../)**', { dot: true, nocase: options.caseSensitiveMatch === false, ignore: processed.transformed diff --git a/src/utils.ts b/src/utils.ts index 4e6b345..33608f8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import picomatch from 'picomatch'; +import unmatch from 'unmatch'; // #region convertPathToPattern const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g; @@ -49,7 +49,7 @@ export function isDynamicPattern(pattern: string, options?: { caseSensitiveMatch return true; } - const scan = picomatch.scan(pattern); + const scan = unmatch.scan(pattern); return scan.isGlob || scan.negated; } // #endregion diff --git a/tsconfig.json b/tsconfig.json index 5913ff3..77fe644 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,8 @@ "noEmit": true, "skipLibCheck": true, - "strict": true + "strict": true, + + "typeRoots": ["./node_modules/@types", "./@types"] } }