void 0.1.6 → 0.7.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/AGENT_PROMPT.md +15 -0
- package/README.md +62 -123
- package/dist/auth-BdsJ0Aff.d.mts +43 -0
- package/dist/auth-cmd-Dx8oPKZC.mjs +43 -0
- package/dist/auth-migrations-BAtAck2g.mjs +117 -0
- package/dist/better-auth-shared-C9_GHSkR.d.mts +71 -0
- package/dist/better-auth-shared-CdYmQGry.mjs +163 -0
- package/dist/cache-W82I8ihI.mjs +47 -0
- package/dist/cancel-deploy-BOBTqqh0.mjs +59 -0
- package/dist/cf-access-Dee5cXxL.mjs +22 -0
- package/dist/chunk-DJd-R1mw.mjs +34 -0
- package/dist/cli/cli.d.mts +1 -0
- package/dist/cli/cli.mjs +1807 -0
- package/dist/client-snXOjrp1.mjs +565 -0
- package/dist/collect-CjeZgz5D.mjs +55 -0
- package/dist/config-BIa9HwVX.mjs +573 -0
- package/dist/config-BzM9Dy7T.mjs +37 -0
- package/dist/config-CvHtTM0q.mjs +30 -0
- package/dist/create-project-BIA15W7z.mjs +90 -0
- package/dist/db-DsRoMcfN.mjs +895 -0
- package/dist/defer-DcxEsVH1.mjs +49 -0
- package/dist/delete-DAP6yDc7.mjs +64 -0
- package/dist/deploy-BPKblFx6.mjs +2424 -0
- package/dist/discover-B7FkXBLB.mjs +40 -0
- package/dist/dist-DUyXJLkq.mjs +2667 -0
- package/dist/dist-Dayj3gCK.mjs +1287 -0
- package/dist/domain-BGofcQ6I.mjs +79 -0
- package/dist/dotenv-DwO4ti0Z.mjs +173 -0
- package/dist/drizzle-NnudE_UN.mjs +232 -0
- package/dist/env-CyG3tvU0.mjs +301 -0
- package/dist/env-helpers-Dr9Y7RnE.d.mts +52 -0
- package/dist/env-raw-BDL4TvdN.mjs +32 -0
- package/dist/env-types-DknSA4SO.mjs +64 -0
- package/dist/env-validation-DJKjR_8q.mjs +163 -0
- package/dist/fetch-error-BQ8sZ5Nd.mjs +266 -0
- package/dist/fetch-error-CVZ5CGA-.d.mts +20 -0
- package/dist/gen-U0Ktr4Zd.mjs +761 -0
- package/dist/handler-B0ds0OHJ.d.mts +269 -0
- package/dist/head-P-egrtFE.d.mts +45 -0
- package/dist/headers-DCXc7mDs.mjs +279 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.mjs +4695 -0
- package/dist/init-C7wS5iGP.mjs +2625 -0
- package/dist/link-p2R6NbgN.mjs +49 -0
- package/dist/list-Bfel-QLc.mjs +113 -0
- package/dist/log-DXdqnmhF.mjs +26 -0
- package/dist/login-CkcXUiIu.mjs +72 -0
- package/dist/logs-DmkrRvx6.mjs +98 -0
- package/dist/magic-string.es-D6g9UnIy.mjs +1011 -0
- package/dist/mcp-CaQzfeUi.mjs +373 -0
- package/dist/node-DDfXj10V.mjs +54 -0
- package/dist/output-BwlcIYSR.mjs +139 -0
- package/dist/pages/client.d.mts +198 -0
- package/dist/pages/client.mjs +980 -0
- package/dist/pages/head-client.d.mts +15 -0
- package/dist/pages/head-client.mjs +90 -0
- package/dist/pages/head.d.mts +2 -0
- package/dist/pages/head.mjs +112 -0
- package/dist/pages/index.d.mts +38 -0
- package/dist/pages/index.mjs +76 -0
- package/dist/pages/islands-plugin.d.mts +50 -0
- package/dist/pages/islands-plugin.mjs +195 -0
- package/dist/pages/prefetch.d.mts +31 -0
- package/dist/pages/prefetch.mjs +90 -0
- package/dist/pages/protocol.d.mts +3 -0
- package/dist/pages/protocol.mjs +193 -0
- package/dist/pages/serialize.d.mts +10 -0
- package/dist/pages/serialize.mjs +14 -0
- package/dist/pathe.M-eThtNZ-D-kmWkCS.mjs +150 -0
- package/dist/plugin-inference-oZ6Ybu2_.mjs +2447 -0
- package/dist/prepare-BAtWufvm.mjs +99 -0
- package/dist/preset-D4I73kT4.mjs +221 -0
- package/dist/project-TqORyHn8.mjs +72 -0
- package/dist/project-cmd-B7lQp3F3.mjs +67 -0
- package/dist/project-slug-CKam8lF9.mjs +11 -0
- package/dist/project-tsconfig-DfkESbDL.mjs +63 -0
- package/dist/protocol-BWzXs2A2.d.mts +34 -0
- package/dist/providers-B3aMxWzP.mjs +67 -0
- package/dist/resolve-project-Br5BR03U.mjs +29 -0
- package/dist/rollback-gyC59l7U.mjs +92 -0
- package/dist/route-types-DReF1gUY.mjs +255 -0
- package/dist/routes-stub.d.mts +55 -0
- package/dist/routes-stub.mjs +1 -0
- package/dist/runner-6Ep3fNQu.mjs +123 -0
- package/dist/runner-pg-D0wWHYnr.mjs +57 -0
- package/dist/runtime/ai.d.mts +127 -0
- package/dist/runtime/ai.mjs +348 -0
- package/dist/runtime/auth-client-react.d.mts +8 -0
- package/dist/runtime/auth-client-react.mjs +6 -0
- package/dist/runtime/auth-client-solid.d.mts +8 -0
- package/dist/runtime/auth-client-solid.mjs +6 -0
- package/dist/runtime/auth-client-svelte.d.mts +8 -0
- package/dist/runtime/auth-client-svelte.mjs +6 -0
- package/dist/runtime/auth-client-vue.d.mts +8 -0
- package/dist/runtime/auth-client-vue.mjs +6 -0
- package/dist/runtime/auth-client.d.mts +8 -0
- package/dist/runtime/auth-client.mjs +6 -0
- package/dist/runtime/auth.d.mts +2 -0
- package/dist/runtime/auth.mjs +22 -0
- package/dist/runtime/better-auth-pg.d.mts +11 -0
- package/dist/runtime/better-auth-pg.mjs +51 -0
- package/dist/runtime/better-auth.d.mts +11 -0
- package/dist/runtime/better-auth.mjs +33 -0
- package/dist/runtime/client.d.mts +6 -0
- package/dist/runtime/client.mjs +5 -0
- package/dist/runtime/db-pg.d.mts +2 -0
- package/dist/runtime/db-pg.mjs +1 -0
- package/dist/runtime/db.d.mts +17 -0
- package/dist/runtime/db.mjs +30 -0
- package/dist/runtime/drizzle-arktype.d.mts +1 -0
- package/dist/runtime/drizzle-arktype.mjs +2 -0
- package/dist/runtime/drizzle-valibot.d.mts +1 -0
- package/dist/runtime/drizzle-valibot.mjs +2 -0
- package/dist/runtime/drizzle-zod.d.mts +1 -0
- package/dist/runtime/drizzle-zod.mjs +2 -0
- package/dist/runtime/env-helpers.d.mts +2 -0
- package/dist/runtime/env-helpers.mjs +173 -0
- package/dist/runtime/env-public-client.d.mts +22 -0
- package/dist/runtime/env-public-client.mjs +54 -0
- package/dist/runtime/env-public.d.mts +143 -0
- package/dist/runtime/env-public.mjs +366 -0
- package/dist/runtime/env.d.mts +13 -0
- package/dist/runtime/env.mjs +51 -0
- package/dist/runtime/fetch-stream.d.mts +51 -0
- package/dist/runtime/fetch-stream.mjs +81 -0
- package/dist/runtime/fetch.d.mts +59 -0
- package/dist/runtime/fetch.mjs +18 -0
- package/dist/runtime/handler.d.mts +3 -0
- package/dist/runtime/handler.mjs +85 -0
- package/dist/runtime/isr.d.mts +26 -0
- package/dist/runtime/isr.mjs +43 -0
- package/dist/runtime/kv.d.mts +48 -0
- package/dist/runtime/kv.mjs +106 -0
- package/dist/runtime/log.d.mts +24 -0
- package/dist/runtime/log.mjs +31 -0
- package/dist/runtime/migration-handler-pg.d.mts +6 -0
- package/dist/runtime/migration-handler-pg.mjs +85 -0
- package/dist/runtime/migration-handler.d.mts +19 -0
- package/dist/runtime/migration-handler.mjs +92 -0
- package/dist/runtime/queues.d.mts +7 -0
- package/dist/runtime/queues.mjs +8 -0
- package/dist/runtime/remote/binding-handler.d.mts +15 -0
- package/dist/runtime/remote/binding-handler.mjs +208 -0
- package/dist/runtime/remote/index.d.mts +8 -0
- package/dist/runtime/remote/index.mjs +461 -0
- package/dist/runtime/response.d.mts +14 -0
- package/dist/runtime/response.mjs +30 -0
- package/dist/runtime/sandbox.d.mts +17 -0
- package/dist/runtime/sandbox.mjs +19 -0
- package/dist/runtime/schema-d1.d.mts +1 -0
- package/dist/runtime/schema-d1.mjs +2 -0
- package/dist/runtime/schema-pg.d.mts +1 -0
- package/dist/runtime/schema-pg.mjs +2 -0
- package/dist/runtime/seed.d.mts +30 -0
- package/dist/runtime/seed.mjs +6 -0
- package/dist/runtime/storage.d.mts +7 -0
- package/dist/runtime/storage.mjs +14 -0
- package/dist/runtime/validator.d.mts +2 -0
- package/dist/runtime/validator.mjs +72 -0
- package/dist/runtime/ws-server.d.mts +26 -0
- package/dist/runtime/ws-server.mjs +296 -0
- package/dist/runtime/ws.d.mts +123 -0
- package/dist/runtime/ws.mjs +103 -0
- package/dist/scan-Ba4hFwlH.mjs +324 -0
- package/dist/scan-C6HMEIdW.mjs +318 -0
- package/dist/secret-CeRSukgM.mjs +109 -0
- package/dist/skills-ipldjlKE.mjs +62 -0
- package/dist/standard-schema-9CRjx-uR.d.mts +42 -0
- package/dist/subcommand-prompt-BKjuNAPb.mjs +349 -0
- package/dist/sveltekit.d.mts +20 -0
- package/dist/sveltekit.mjs +61 -0
- package/dist/types-mHOEwpW4.d.mts +57 -0
- package/dist/validate-CaMavMxu.mjs +146 -0
- package/dist/yarn-pnp-BFqMV_bl.mjs +196 -0
- package/getting-started-prompt.txt +26 -0
- package/package.json +322 -30
- package/schema.json +364 -0
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/SKILL.md +75 -0
- package/skills/void/command/void.md +7 -0
- package/skills/void/docs/guide/ai.md +235 -0
- package/skills/void/docs/guide/app-types.md +103 -0
- package/skills/void/docs/guide/auth.md +257 -0
- package/skills/void/docs/guide/database/d1.md +106 -0
- package/skills/void/docs/guide/database/postgresql.md +106 -0
- package/skills/void/docs/guide/database.md +418 -0
- package/skills/void/docs/guide/deployment.md +98 -0
- package/skills/void/docs/guide/edge/headers.md +79 -0
- package/skills/void/docs/guide/edge/prerendering.md +83 -0
- package/skills/void/docs/guide/edge/redirects.md +116 -0
- package/skills/void/docs/guide/edge/revalidation.md +131 -0
- package/skills/void/docs/guide/edge/rewrites.md +354 -0
- package/skills/void/docs/guide/edge/static-assets.md +72 -0
- package/skills/void/docs/guide/env-vars.md +298 -0
- package/skills/void/docs/guide/index.md +80 -0
- package/skills/void/docs/guide/jobs.md +91 -0
- package/skills/void/docs/guide/kv.md +107 -0
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +419 -0
- package/skills/void/docs/guide/pages-routing/head.md +130 -0
- package/skills/void/docs/guide/pages-routing/islands.md +405 -0
- package/skills/void/docs/guide/pages-routing/layouts.md +362 -0
- package/skills/void/docs/guide/pages-routing/loaders.md +267 -0
- package/skills/void/docs/guide/pages-routing/markdown.md +625 -0
- package/skills/void/docs/guide/pages-routing/overview.md +236 -0
- package/skills/void/docs/guide/pages-routing/view-transitions.md +140 -0
- package/skills/void/docs/guide/queues.md +140 -0
- package/skills/void/docs/guide/quickstart.md +233 -0
- package/skills/void/docs/guide/remote-dev.md +67 -0
- package/skills/void/docs/guide/sandboxes.md +82 -0
- package/skills/void/docs/guide/server-routing.md +246 -0
- package/skills/void/docs/guide/ssg.md +74 -0
- package/skills/void/docs/guide/ssr.md +105 -0
- package/skills/void/docs/guide/storage.md +67 -0
- package/skills/void/docs/guide/type-safety.md +179 -0
- package/skills/void/docs/guide/typed-fetch.md +113 -0
- package/skills/void/docs/guide/websockets.md +190 -0
- package/skills/void/docs/index.md +48 -0
- package/skills/void/docs/integrations/agents.md +84 -0
- package/skills/void/docs/integrations/cloudflare.md +284 -0
- package/skills/void/docs/integrations/frameworks/analog.md +182 -0
- package/skills/void/docs/integrations/frameworks/astro.md +197 -0
- package/skills/void/docs/integrations/frameworks/nuxt.md +164 -0
- package/skills/void/docs/integrations/frameworks/overview.md +136 -0
- package/skills/void/docs/integrations/frameworks/react-router.md +137 -0
- package/skills/void/docs/integrations/frameworks/sveltekit.md +191 -0
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +140 -0
- package/skills/void/docs/integrations/hono.md +97 -0
- package/skills/void/docs/integrations/nodejs-bun-deno.md +210 -0
- package/skills/void/docs/node_modules/@iconify/vue/README.md +408 -0
- package/skills/void/docs/node_modules/@iconify/vue/offline/readme.md +5 -0
- package/skills/void/docs/node_modules/@voidzero-dev/vitepress-theme/README.md +103 -0
- package/skills/void/docs/node_modules/oxc-minify/README.md +78 -0
- package/skills/void/docs/node_modules/reka-ui/README.md +80 -0
- package/skills/void/docs/node_modules/vitepress/README.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/api-examples.md +49 -0
- package/skills/void/docs/node_modules/vitepress/template/index.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/markdown-examples.md +85 -0
- package/skills/void/docs/node_modules/vitepress-plugin-group-icons/README.md +101 -0
- package/skills/void/docs/node_modules/void/AGENTS.md +204 -0
- package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +15 -0
- package/skills/void/docs/node_modules/void/README.md +89 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +591 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +375 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +174 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/vite-plugin/README.md +37 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/workers-types/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +189 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/CHANGELOG.md +143 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/README.md +1272 -0
- package/skills/void/docs/node_modules/void/node_modules/@napi-rs/keyring/README.md +19 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/better-sqlite3/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/pg/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/README.md +22 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/vendor/vscode-jsonrpc/README.md +69 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/README.md +152 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/engine-javascript/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/transformers/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/CHANGELOG.md +24 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/README.md +565 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +124 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-anchor/README.md +600 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-attrs/README.md +386 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-container/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-emoji/README.md +101 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/shiki/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vue/README.md +58 -0
- package/skills/void/docs/node_modules/void/node_modules/arktype/README.md +165 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/LICENSE.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/README.md +32 -0
- package/skills/void/docs/node_modules/void/node_modules/better-sqlite3/README.md +99 -0
- package/skills/void/docs/node_modules/void/node_modules/blake3-jit/README.md +108 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-arktype/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-kit/README.md +79 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-orm/README.md +44 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-valibot/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-zod/README.md +65 -0
- package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +390 -0
- package/skills/void/docs/node_modules/void/node_modules/estree-walker/README.md +48 -0
- package/skills/void/docs/node_modules/void/node_modules/hono/README.md +85 -0
- package/skills/void/docs/node_modules/void/node_modules/ignore/README.md +452 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/{LICENSE → skills/void/docs/node_modules/void/node_modules/jsonc-parser/LICENSE.md} +21 -21
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/README.md +364 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/skills/void/docs/node_modules/void/node_modules/magic-string/README.md +325 -0
- package/skills/void/docs/node_modules/void/node_modules/ofetch/README.md +398 -0
- package/skills/void/docs/node_modules/void/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/pg/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/LICENSE.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/picocolors/README.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/LICENSE.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/README.md +94 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/wrangler/README.md +63 -0
- package/skills/void/docs/node_modules/void/node_modules/zod/README.md +191 -0
- package/skills/void/docs/node_modules/void/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/docs/node_modules/void/skills/void/SKILL.md +75 -0
- package/skills/void/docs/node_modules/void/skills/void/command/void.md +7 -0
- package/skills/void/docs/reference/api.md +917 -0
- package/skills/void/docs/reference/cli.md +561 -0
- package/skills/void/docs/reference/config.md +408 -0
- package/skills/void/docs/reference/resource-inference.md +149 -0
- package/skills/void/docs/reference/structure.md +176 -0
- package/.npmignore +0 -29
- package/.travis.yml +0 -9
- package/favicon.ico +0 -0
- package/index.js +0 -14
- package/lib/Job.js +0 -150
- package/lib/Void.js +0 -99
- package/lib/scan.js +0 -19
- package/test/credentials.js +0 -20
- package/test/job.js +0 -64
- package/test/static/dir1/test6.html +0 -0
- package/test/static/dir2/test7.html +0 -0
- package/test/static/dir2/test8.html +0 -0
- package/test/static/dir2/test9.html +0 -0
- package/test/static/test1.html +0 -0
- package/test/static/test2.html +0 -0
- package/test/static/test3.html +0 -0
- package/test/void.js +0 -31
- /package/{test/static/dir1/test4.html → skills/void/docs/integrations/auth-providers.md} +0 -0
- /package/{test/static/dir1/test5.html → skills/void/docs/integrations/payment-processors.md} +0 -0
|
@@ -0,0 +1,2667 @@
|
|
|
1
|
+
import { r as __toESM, t as __commonJSMin } from "./chunk-DJd-R1mw.mjs";
|
|
2
|
+
import * as nativeFs from "fs";
|
|
3
|
+
import { readdir, readdirSync, realpath, realpathSync, stat, statSync } from "fs";
|
|
4
|
+
import { basename, dirname, isAbsolute, normalize, posix, relative, resolve, sep } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
//#region ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.4/node_modules/fdir/dist/index.mjs
|
|
8
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
9
|
+
function cleanPath(path) {
|
|
10
|
+
let normalized = normalize(path);
|
|
11
|
+
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
12
|
+
return normalized;
|
|
13
|
+
}
|
|
14
|
+
const SLASHES_REGEX = /[\\/]/g;
|
|
15
|
+
function convertSlashes(path, separator) {
|
|
16
|
+
return path.replace(SLASHES_REGEX, separator);
|
|
17
|
+
}
|
|
18
|
+
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
19
|
+
function isRootDirectory(path) {
|
|
20
|
+
return path === "/" || WINDOWS_ROOT_DIR_REGEX.test(path);
|
|
21
|
+
}
|
|
22
|
+
function normalizePath(path, options) {
|
|
23
|
+
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
24
|
+
const pathNeedsCleaning = process.platform === "win32" && path.includes("/") || path.startsWith(".");
|
|
25
|
+
if (resolvePaths) path = resolve(path);
|
|
26
|
+
if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
|
|
27
|
+
if (path === ".") return "";
|
|
28
|
+
return convertSlashes(path[path.length - 1] !== pathSeparator ? path + pathSeparator : path, pathSeparator);
|
|
29
|
+
}
|
|
30
|
+
function joinPathWithBasePath(filename, directoryPath) {
|
|
31
|
+
return directoryPath + filename;
|
|
32
|
+
}
|
|
33
|
+
function joinPathWithRelativePath(root, options) {
|
|
34
|
+
return function(filename, directoryPath) {
|
|
35
|
+
if (directoryPath.startsWith(root)) return directoryPath.slice(root.length) + filename;
|
|
36
|
+
else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function joinPath(filename) {
|
|
40
|
+
return filename;
|
|
41
|
+
}
|
|
42
|
+
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
43
|
+
return directoryPath + filename + separator;
|
|
44
|
+
}
|
|
45
|
+
function build$7(root, options) {
|
|
46
|
+
const { relativePaths, includeBasePath } = options;
|
|
47
|
+
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
48
|
+
}
|
|
49
|
+
function pushDirectoryWithRelativePath(root) {
|
|
50
|
+
return function(directoryPath, paths) {
|
|
51
|
+
paths.push(directoryPath.substring(root.length) || ".");
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function pushDirectoryFilterWithRelativePath(root) {
|
|
55
|
+
return function(directoryPath, paths, filters) {
|
|
56
|
+
const relativePath = directoryPath.substring(root.length) || ".";
|
|
57
|
+
if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const pushDirectory = (directoryPath, paths) => {
|
|
61
|
+
paths.push(directoryPath || ".");
|
|
62
|
+
};
|
|
63
|
+
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
64
|
+
const path = directoryPath || ".";
|
|
65
|
+
if (filters.every((filter) => filter(path, true))) paths.push(path);
|
|
66
|
+
};
|
|
67
|
+
const empty$2 = () => {};
|
|
68
|
+
function build$6(root, options) {
|
|
69
|
+
const { includeDirs, filters, relativePaths } = options;
|
|
70
|
+
if (!includeDirs) return empty$2;
|
|
71
|
+
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
72
|
+
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
73
|
+
}
|
|
74
|
+
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
75
|
+
if (filters.every((filter) => filter(filename, false))) counts.files++;
|
|
76
|
+
};
|
|
77
|
+
const pushFileFilter = (filename, paths, _counts, filters) => {
|
|
78
|
+
if (filters.every((filter) => filter(filename, false))) paths.push(filename);
|
|
79
|
+
};
|
|
80
|
+
const pushFileCount = (_filename, _paths, counts, _filters) => {
|
|
81
|
+
counts.files++;
|
|
82
|
+
};
|
|
83
|
+
const pushFile = (filename, paths) => {
|
|
84
|
+
paths.push(filename);
|
|
85
|
+
};
|
|
86
|
+
const empty$1 = () => {};
|
|
87
|
+
function build$5(options) {
|
|
88
|
+
const { excludeFiles, filters, onlyCounts } = options;
|
|
89
|
+
if (excludeFiles) return empty$1;
|
|
90
|
+
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
91
|
+
else if (onlyCounts) return pushFileCount;
|
|
92
|
+
else return pushFile;
|
|
93
|
+
}
|
|
94
|
+
const getArray = (paths) => {
|
|
95
|
+
return paths;
|
|
96
|
+
};
|
|
97
|
+
const getArrayGroup = () => {
|
|
98
|
+
return [""].slice(0, 0);
|
|
99
|
+
};
|
|
100
|
+
function build$4(options) {
|
|
101
|
+
return options.group ? getArrayGroup : getArray;
|
|
102
|
+
}
|
|
103
|
+
const groupFiles = (groups, directory, files) => {
|
|
104
|
+
groups.push({
|
|
105
|
+
directory,
|
|
106
|
+
files,
|
|
107
|
+
dir: directory
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const empty = () => {};
|
|
111
|
+
function build$3(options) {
|
|
112
|
+
return options.group ? groupFiles : empty;
|
|
113
|
+
}
|
|
114
|
+
const resolveSymlinksAsync = function(path, state, callback$1) {
|
|
115
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
116
|
+
queue.enqueue();
|
|
117
|
+
fs.realpath(path, (error, resolvedPath) => {
|
|
118
|
+
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
119
|
+
fs.stat(resolvedPath, (error$1, stat) => {
|
|
120
|
+
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
121
|
+
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
|
|
122
|
+
callback$1(stat, resolvedPath);
|
|
123
|
+
queue.dequeue(null, state);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
const resolveSymlinks = function(path, state, callback$1) {
|
|
128
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
129
|
+
queue.enqueue();
|
|
130
|
+
try {
|
|
131
|
+
const resolvedPath = fs.realpathSync(path);
|
|
132
|
+
const stat = fs.statSync(resolvedPath);
|
|
133
|
+
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
|
|
134
|
+
callback$1(stat, resolvedPath);
|
|
135
|
+
} catch (e) {
|
|
136
|
+
if (!suppressErrors) throw e;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
function build$2(options, isSynchronous) {
|
|
140
|
+
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
141
|
+
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
142
|
+
}
|
|
143
|
+
function isRecursive(path, resolved, state) {
|
|
144
|
+
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
145
|
+
let parent = dirname(path);
|
|
146
|
+
let depth = 1;
|
|
147
|
+
while (parent !== state.root && depth < 2) {
|
|
148
|
+
const resolvedPath = state.symlinks.get(parent);
|
|
149
|
+
if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth++;
|
|
150
|
+
else parent = dirname(parent);
|
|
151
|
+
}
|
|
152
|
+
state.symlinks.set(path, resolved);
|
|
153
|
+
return depth > 1;
|
|
154
|
+
}
|
|
155
|
+
function isRecursiveUsingRealPaths(resolved, state) {
|
|
156
|
+
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
157
|
+
}
|
|
158
|
+
const onlyCountsSync = (state) => {
|
|
159
|
+
return state.counts;
|
|
160
|
+
};
|
|
161
|
+
const groupsSync = (state) => {
|
|
162
|
+
return state.groups;
|
|
163
|
+
};
|
|
164
|
+
const defaultSync = (state) => {
|
|
165
|
+
return state.paths;
|
|
166
|
+
};
|
|
167
|
+
const limitFilesSync = (state) => {
|
|
168
|
+
return state.paths.slice(0, state.options.maxFiles);
|
|
169
|
+
};
|
|
170
|
+
const onlyCountsAsync = (state, error, callback$1) => {
|
|
171
|
+
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
172
|
+
return null;
|
|
173
|
+
};
|
|
174
|
+
const defaultAsync = (state, error, callback$1) => {
|
|
175
|
+
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
176
|
+
return null;
|
|
177
|
+
};
|
|
178
|
+
const limitFilesAsync = (state, error, callback$1) => {
|
|
179
|
+
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
180
|
+
return null;
|
|
181
|
+
};
|
|
182
|
+
const groupsAsync = (state, error, callback$1) => {
|
|
183
|
+
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
184
|
+
return null;
|
|
185
|
+
};
|
|
186
|
+
function report(error, callback$1, output, suppressErrors) {
|
|
187
|
+
if (error && !suppressErrors) callback$1(error, output);
|
|
188
|
+
else callback$1(null, output);
|
|
189
|
+
}
|
|
190
|
+
function build$1(options, isSynchronous) {
|
|
191
|
+
const { onlyCounts, group, maxFiles } = options;
|
|
192
|
+
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
193
|
+
else if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
194
|
+
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
195
|
+
else return isSynchronous ? defaultSync : defaultAsync;
|
|
196
|
+
}
|
|
197
|
+
const readdirOpts = { withFileTypes: true };
|
|
198
|
+
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
199
|
+
state.queue.enqueue();
|
|
200
|
+
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
201
|
+
const { fs } = state;
|
|
202
|
+
state.visited.push(crawlPath);
|
|
203
|
+
state.counts.directories++;
|
|
204
|
+
fs.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
205
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
206
|
+
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
210
|
+
const { fs } = state;
|
|
211
|
+
if (currentDepth < 0) return;
|
|
212
|
+
state.visited.push(crawlPath);
|
|
213
|
+
state.counts.directories++;
|
|
214
|
+
let entries = [];
|
|
215
|
+
try {
|
|
216
|
+
entries = fs.readdirSync(crawlPath || ".", readdirOpts);
|
|
217
|
+
} catch (e) {
|
|
218
|
+
if (!state.options.suppressErrors) throw e;
|
|
219
|
+
}
|
|
220
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
221
|
+
};
|
|
222
|
+
function build(isSynchronous) {
|
|
223
|
+
return isSynchronous ? walkSync : walkAsync;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* This is a custom stateless queue to track concurrent async fs calls.
|
|
227
|
+
* It increments a counter whenever a call is queued and decrements it
|
|
228
|
+
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
|
229
|
+
*/
|
|
230
|
+
var Queue = class {
|
|
231
|
+
count = 0;
|
|
232
|
+
constructor(onQueueEmpty) {
|
|
233
|
+
this.onQueueEmpty = onQueueEmpty;
|
|
234
|
+
}
|
|
235
|
+
enqueue() {
|
|
236
|
+
this.count++;
|
|
237
|
+
return this.count;
|
|
238
|
+
}
|
|
239
|
+
dequeue(error, output) {
|
|
240
|
+
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
241
|
+
this.onQueueEmpty(error, output);
|
|
242
|
+
if (error) {
|
|
243
|
+
output.controller.abort();
|
|
244
|
+
this.onQueueEmpty = void 0;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
var Counter = class {
|
|
250
|
+
_files = 0;
|
|
251
|
+
_directories = 0;
|
|
252
|
+
set files(num) {
|
|
253
|
+
this._files = num;
|
|
254
|
+
}
|
|
255
|
+
get files() {
|
|
256
|
+
return this._files;
|
|
257
|
+
}
|
|
258
|
+
set directories(num) {
|
|
259
|
+
this._directories = num;
|
|
260
|
+
}
|
|
261
|
+
get directories() {
|
|
262
|
+
return this._directories;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* @deprecated use `directories` instead
|
|
266
|
+
*/
|
|
267
|
+
/* c8 ignore next 3 */
|
|
268
|
+
get dirs() {
|
|
269
|
+
return this._directories;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* AbortController is not supported on Node 14 so we use this until we can drop
|
|
274
|
+
* support for Node 14.
|
|
275
|
+
*/
|
|
276
|
+
var Aborter = class {
|
|
277
|
+
aborted = false;
|
|
278
|
+
abort() {
|
|
279
|
+
this.aborted = true;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
var Walker = class {
|
|
283
|
+
root;
|
|
284
|
+
isSynchronous;
|
|
285
|
+
state;
|
|
286
|
+
joinPath;
|
|
287
|
+
pushDirectory;
|
|
288
|
+
pushFile;
|
|
289
|
+
getArray;
|
|
290
|
+
groupFiles;
|
|
291
|
+
resolveSymlink;
|
|
292
|
+
walkDirectory;
|
|
293
|
+
callbackInvoker;
|
|
294
|
+
constructor(root, options, callback$1) {
|
|
295
|
+
this.isSynchronous = !callback$1;
|
|
296
|
+
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
297
|
+
this.root = normalizePath(root, options);
|
|
298
|
+
this.state = {
|
|
299
|
+
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
300
|
+
paths: [""].slice(0, 0),
|
|
301
|
+
groups: [],
|
|
302
|
+
counts: new Counter(),
|
|
303
|
+
options,
|
|
304
|
+
queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
|
|
305
|
+
symlinks: /* @__PURE__ */ new Map(),
|
|
306
|
+
visited: [""].slice(0, 0),
|
|
307
|
+
controller: new Aborter(),
|
|
308
|
+
fs: options.fs || nativeFs
|
|
309
|
+
};
|
|
310
|
+
this.joinPath = build$7(this.root, options);
|
|
311
|
+
this.pushDirectory = build$6(this.root, options);
|
|
312
|
+
this.pushFile = build$5(options);
|
|
313
|
+
this.getArray = build$4(options);
|
|
314
|
+
this.groupFiles = build$3(options);
|
|
315
|
+
this.resolveSymlink = build$2(options, this.isSynchronous);
|
|
316
|
+
this.walkDirectory = build(this.isSynchronous);
|
|
317
|
+
}
|
|
318
|
+
start() {
|
|
319
|
+
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
320
|
+
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
321
|
+
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
322
|
+
}
|
|
323
|
+
walk = (entries, directoryPath, depth) => {
|
|
324
|
+
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
325
|
+
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
326
|
+
const files = this.getArray(this.state.paths);
|
|
327
|
+
for (let i = 0; i < entries.length; ++i) {
|
|
328
|
+
const entry = entries[i];
|
|
329
|
+
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
330
|
+
const filename = this.joinPath(entry.name, directoryPath);
|
|
331
|
+
this.pushFile(filename, files, this.state.counts, filters);
|
|
332
|
+
} else if (entry.isDirectory()) {
|
|
333
|
+
let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
334
|
+
if (exclude && exclude(entry.name, path)) continue;
|
|
335
|
+
this.pushDirectory(path, paths, filters);
|
|
336
|
+
this.walkDirectory(this.state, path, path, depth - 1, this.walk);
|
|
337
|
+
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
338
|
+
let path = joinPathWithBasePath(entry.name, directoryPath);
|
|
339
|
+
this.resolveSymlink(path, this.state, (stat, resolvedPath) => {
|
|
340
|
+
if (stat.isDirectory()) {
|
|
341
|
+
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
342
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
|
|
343
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
|
|
344
|
+
} else {
|
|
345
|
+
resolvedPath = useRealPaths ? resolvedPath : path;
|
|
346
|
+
const filename = basename(resolvedPath);
|
|
347
|
+
const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
|
|
348
|
+
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
349
|
+
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
this.groupFiles(this.state.groups, directoryPath, files);
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
function promise(root, options) {
|
|
358
|
+
return new Promise((resolve$1, reject) => {
|
|
359
|
+
callback(root, options, (err, output) => {
|
|
360
|
+
if (err) return reject(err);
|
|
361
|
+
resolve$1(output);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function callback(root, options, callback$1) {
|
|
366
|
+
new Walker(root, options, callback$1).start();
|
|
367
|
+
}
|
|
368
|
+
function sync(root, options) {
|
|
369
|
+
return new Walker(root, options).start();
|
|
370
|
+
}
|
|
371
|
+
var APIBuilder = class {
|
|
372
|
+
constructor(root, options) {
|
|
373
|
+
this.root = root;
|
|
374
|
+
this.options = options;
|
|
375
|
+
}
|
|
376
|
+
withPromise() {
|
|
377
|
+
return promise(this.root, this.options);
|
|
378
|
+
}
|
|
379
|
+
withCallback(cb) {
|
|
380
|
+
callback(this.root, this.options, cb);
|
|
381
|
+
}
|
|
382
|
+
sync() {
|
|
383
|
+
return sync(this.root, this.options);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
let pm = null;
|
|
387
|
+
/* c8 ignore next 6 */
|
|
388
|
+
try {
|
|
389
|
+
__require.resolve("picomatch");
|
|
390
|
+
pm = __require("picomatch");
|
|
391
|
+
} catch {}
|
|
392
|
+
var Builder = class {
|
|
393
|
+
globCache = {};
|
|
394
|
+
options = {
|
|
395
|
+
maxDepth: Infinity,
|
|
396
|
+
suppressErrors: true,
|
|
397
|
+
pathSeparator: sep,
|
|
398
|
+
filters: []
|
|
399
|
+
};
|
|
400
|
+
globFunction;
|
|
401
|
+
constructor(options) {
|
|
402
|
+
this.options = {
|
|
403
|
+
...this.options,
|
|
404
|
+
...options
|
|
405
|
+
};
|
|
406
|
+
this.globFunction = this.options.globFunction;
|
|
407
|
+
}
|
|
408
|
+
group() {
|
|
409
|
+
this.options.group = true;
|
|
410
|
+
return this;
|
|
411
|
+
}
|
|
412
|
+
withPathSeparator(separator) {
|
|
413
|
+
this.options.pathSeparator = separator;
|
|
414
|
+
return this;
|
|
415
|
+
}
|
|
416
|
+
withBasePath() {
|
|
417
|
+
this.options.includeBasePath = true;
|
|
418
|
+
return this;
|
|
419
|
+
}
|
|
420
|
+
withRelativePaths() {
|
|
421
|
+
this.options.relativePaths = true;
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
withDirs() {
|
|
425
|
+
this.options.includeDirs = true;
|
|
426
|
+
return this;
|
|
427
|
+
}
|
|
428
|
+
withMaxDepth(depth) {
|
|
429
|
+
this.options.maxDepth = depth;
|
|
430
|
+
return this;
|
|
431
|
+
}
|
|
432
|
+
withMaxFiles(limit) {
|
|
433
|
+
this.options.maxFiles = limit;
|
|
434
|
+
return this;
|
|
435
|
+
}
|
|
436
|
+
withFullPaths() {
|
|
437
|
+
this.options.resolvePaths = true;
|
|
438
|
+
this.options.includeBasePath = true;
|
|
439
|
+
return this;
|
|
440
|
+
}
|
|
441
|
+
withErrors() {
|
|
442
|
+
this.options.suppressErrors = false;
|
|
443
|
+
return this;
|
|
444
|
+
}
|
|
445
|
+
withSymlinks({ resolvePaths = true } = {}) {
|
|
446
|
+
this.options.resolveSymlinks = true;
|
|
447
|
+
this.options.useRealPaths = resolvePaths;
|
|
448
|
+
return this.withFullPaths();
|
|
449
|
+
}
|
|
450
|
+
withAbortSignal(signal) {
|
|
451
|
+
this.options.signal = signal;
|
|
452
|
+
return this;
|
|
453
|
+
}
|
|
454
|
+
normalize() {
|
|
455
|
+
this.options.normalizePath = true;
|
|
456
|
+
return this;
|
|
457
|
+
}
|
|
458
|
+
filter(predicate) {
|
|
459
|
+
this.options.filters.push(predicate);
|
|
460
|
+
return this;
|
|
461
|
+
}
|
|
462
|
+
onlyDirs() {
|
|
463
|
+
this.options.excludeFiles = true;
|
|
464
|
+
this.options.includeDirs = true;
|
|
465
|
+
return this;
|
|
466
|
+
}
|
|
467
|
+
exclude(predicate) {
|
|
468
|
+
this.options.exclude = predicate;
|
|
469
|
+
return this;
|
|
470
|
+
}
|
|
471
|
+
onlyCounts() {
|
|
472
|
+
this.options.onlyCounts = true;
|
|
473
|
+
return this;
|
|
474
|
+
}
|
|
475
|
+
crawl(root) {
|
|
476
|
+
return new APIBuilder(root || ".", this.options);
|
|
477
|
+
}
|
|
478
|
+
withGlobFunction(fn) {
|
|
479
|
+
this.globFunction = fn;
|
|
480
|
+
return this;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* @deprecated Pass options using the constructor instead:
|
|
484
|
+
* ```ts
|
|
485
|
+
* new fdir(options).crawl("/path/to/root");
|
|
486
|
+
* ```
|
|
487
|
+
* This method will be removed in v7.0
|
|
488
|
+
*/
|
|
489
|
+
/* c8 ignore next 4 */
|
|
490
|
+
crawlWithOptions(root, options) {
|
|
491
|
+
this.options = {
|
|
492
|
+
...this.options,
|
|
493
|
+
...options
|
|
494
|
+
};
|
|
495
|
+
return new APIBuilder(root || ".", this.options);
|
|
496
|
+
}
|
|
497
|
+
glob(...patterns) {
|
|
498
|
+
if (this.globFunction) return this.globWithOptions(patterns);
|
|
499
|
+
return this.globWithOptions(patterns, ...[{ dot: true }]);
|
|
500
|
+
}
|
|
501
|
+
globWithOptions(patterns, ...options) {
|
|
502
|
+
const globFn = this.globFunction || pm;
|
|
503
|
+
/* c8 ignore next 5 */
|
|
504
|
+
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
505
|
+
var isMatch = this.globCache[patterns.join("\0")];
|
|
506
|
+
if (!isMatch) {
|
|
507
|
+
isMatch = globFn(patterns, ...options);
|
|
508
|
+
this.globCache[patterns.join("\0")] = isMatch;
|
|
509
|
+
}
|
|
510
|
+
this.options.filters.push((path) => isMatch(path));
|
|
511
|
+
return this;
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js
|
|
516
|
+
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
517
|
+
const WIN_SLASH = "\\\\/";
|
|
518
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
519
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
520
|
+
/**
|
|
521
|
+
* Posix glob regex
|
|
522
|
+
*/
|
|
523
|
+
const DOT_LITERAL = "\\.";
|
|
524
|
+
const PLUS_LITERAL = "\\+";
|
|
525
|
+
const QMARK_LITERAL = "\\?";
|
|
526
|
+
const SLASH_LITERAL = "\\/";
|
|
527
|
+
const ONE_CHAR = "(?=.)";
|
|
528
|
+
const QMARK = "[^/]";
|
|
529
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
530
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
531
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
532
|
+
const POSIX_CHARS = {
|
|
533
|
+
DOT_LITERAL,
|
|
534
|
+
PLUS_LITERAL,
|
|
535
|
+
QMARK_LITERAL,
|
|
536
|
+
SLASH_LITERAL,
|
|
537
|
+
ONE_CHAR,
|
|
538
|
+
QMARK,
|
|
539
|
+
END_ANCHOR,
|
|
540
|
+
DOTS_SLASH,
|
|
541
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
542
|
+
NO_DOTS: `(?!${START_ANCHOR}${DOTS_SLASH})`,
|
|
543
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`,
|
|
544
|
+
NO_DOTS_SLASH: `(?!${DOTS_SLASH})`,
|
|
545
|
+
QMARK_NO_DOT: `[^.${SLASH_LITERAL}]`,
|
|
546
|
+
STAR: `${QMARK}*?`,
|
|
547
|
+
START_ANCHOR,
|
|
548
|
+
SEP: "/"
|
|
549
|
+
};
|
|
550
|
+
/**
|
|
551
|
+
* Windows glob regex
|
|
552
|
+
*/
|
|
553
|
+
const WINDOWS_CHARS = {
|
|
554
|
+
...POSIX_CHARS,
|
|
555
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
556
|
+
QMARK: WIN_NO_SLASH,
|
|
557
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
558
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
559
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
560
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
561
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
562
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
563
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
564
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
565
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
566
|
+
SEP: "\\"
|
|
567
|
+
};
|
|
568
|
+
module.exports = {
|
|
569
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
570
|
+
MAX_LENGTH: 1024 * 64,
|
|
571
|
+
POSIX_REGEX_SOURCE: {
|
|
572
|
+
__proto__: null,
|
|
573
|
+
alnum: "a-zA-Z0-9",
|
|
574
|
+
alpha: "a-zA-Z",
|
|
575
|
+
ascii: "\\x00-\\x7F",
|
|
576
|
+
blank: " \\t",
|
|
577
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
578
|
+
digit: "0-9",
|
|
579
|
+
graph: "\\x21-\\x7E",
|
|
580
|
+
lower: "a-z",
|
|
581
|
+
print: "\\x20-\\x7E ",
|
|
582
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
583
|
+
space: " \\t\\r\\n\\v\\f",
|
|
584
|
+
upper: "A-Z",
|
|
585
|
+
word: "A-Za-z0-9_",
|
|
586
|
+
xdigit: "A-Fa-f0-9"
|
|
587
|
+
},
|
|
588
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
589
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
590
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
591
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
592
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
593
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
594
|
+
REPLACEMENTS: {
|
|
595
|
+
__proto__: null,
|
|
596
|
+
"***": "*",
|
|
597
|
+
"**/**": "**",
|
|
598
|
+
"**/**/**": "**"
|
|
599
|
+
},
|
|
600
|
+
CHAR_0: 48,
|
|
601
|
+
CHAR_9: 57,
|
|
602
|
+
CHAR_UPPERCASE_A: 65,
|
|
603
|
+
CHAR_LOWERCASE_A: 97,
|
|
604
|
+
CHAR_UPPERCASE_Z: 90,
|
|
605
|
+
CHAR_LOWERCASE_Z: 122,
|
|
606
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
607
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
608
|
+
CHAR_ASTERISK: 42,
|
|
609
|
+
CHAR_AMPERSAND: 38,
|
|
610
|
+
CHAR_AT: 64,
|
|
611
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
612
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
613
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
614
|
+
CHAR_COLON: 58,
|
|
615
|
+
CHAR_COMMA: 44,
|
|
616
|
+
CHAR_DOT: 46,
|
|
617
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
618
|
+
CHAR_EQUAL: 61,
|
|
619
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
620
|
+
CHAR_FORM_FEED: 12,
|
|
621
|
+
CHAR_FORWARD_SLASH: 47,
|
|
622
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
623
|
+
CHAR_HASH: 35,
|
|
624
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
625
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
626
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
627
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
628
|
+
CHAR_LINE_FEED: 10,
|
|
629
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
630
|
+
CHAR_PERCENT: 37,
|
|
631
|
+
CHAR_PLUS: 43,
|
|
632
|
+
CHAR_QUESTION_MARK: 63,
|
|
633
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
634
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
635
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
636
|
+
CHAR_SEMICOLON: 59,
|
|
637
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
638
|
+
CHAR_SPACE: 32,
|
|
639
|
+
CHAR_TAB: 9,
|
|
640
|
+
CHAR_UNDERSCORE: 95,
|
|
641
|
+
CHAR_VERTICAL_LINE: 124,
|
|
642
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
643
|
+
/**
|
|
644
|
+
* Create EXTGLOB_CHARS
|
|
645
|
+
*/
|
|
646
|
+
extglobChars(chars) {
|
|
647
|
+
return {
|
|
648
|
+
"!": {
|
|
649
|
+
type: "negate",
|
|
650
|
+
open: "(?:(?!(?:",
|
|
651
|
+
close: `))${chars.STAR})`
|
|
652
|
+
},
|
|
653
|
+
"?": {
|
|
654
|
+
type: "qmark",
|
|
655
|
+
open: "(?:",
|
|
656
|
+
close: ")?"
|
|
657
|
+
},
|
|
658
|
+
"+": {
|
|
659
|
+
type: "plus",
|
|
660
|
+
open: "(?:",
|
|
661
|
+
close: ")+"
|
|
662
|
+
},
|
|
663
|
+
"*": {
|
|
664
|
+
type: "star",
|
|
665
|
+
open: "(?:",
|
|
666
|
+
close: ")*"
|
|
667
|
+
},
|
|
668
|
+
"@": {
|
|
669
|
+
type: "at",
|
|
670
|
+
open: "(?:",
|
|
671
|
+
close: ")"
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
},
|
|
675
|
+
/**
|
|
676
|
+
* Create GLOB_CHARS
|
|
677
|
+
*/
|
|
678
|
+
globChars(win32) {
|
|
679
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
}));
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js
|
|
685
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
686
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
687
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
688
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
689
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
690
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
691
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
692
|
+
exports.isWindows = () => {
|
|
693
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
694
|
+
const platform = navigator.platform.toLowerCase();
|
|
695
|
+
return platform === "win32" || platform === "windows";
|
|
696
|
+
}
|
|
697
|
+
if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
|
|
698
|
+
return false;
|
|
699
|
+
};
|
|
700
|
+
exports.removeBackslashes = (str) => {
|
|
701
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
702
|
+
return match === "\\" ? "" : match;
|
|
703
|
+
});
|
|
704
|
+
};
|
|
705
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
706
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
707
|
+
if (idx === -1) return input;
|
|
708
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
709
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
710
|
+
};
|
|
711
|
+
exports.removePrefix = (input, state = {}) => {
|
|
712
|
+
let output = input;
|
|
713
|
+
if (output.startsWith("./")) {
|
|
714
|
+
output = output.slice(2);
|
|
715
|
+
state.prefix = "./";
|
|
716
|
+
}
|
|
717
|
+
return output;
|
|
718
|
+
};
|
|
719
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
720
|
+
let output = `${options.contains ? "" : "^"}(?:${input})${options.contains ? "" : "$"}`;
|
|
721
|
+
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
722
|
+
return output;
|
|
723
|
+
};
|
|
724
|
+
exports.basename = (path, { windows } = {}) => {
|
|
725
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
726
|
+
const last = segs[segs.length - 1];
|
|
727
|
+
if (last === "") return segs[segs.length - 2];
|
|
728
|
+
return last;
|
|
729
|
+
};
|
|
730
|
+
}));
|
|
731
|
+
//#endregion
|
|
732
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js
|
|
733
|
+
var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
734
|
+
const utils = require_utils();
|
|
735
|
+
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
736
|
+
const isPathSeparator = (code) => {
|
|
737
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
738
|
+
};
|
|
739
|
+
const depth = (token) => {
|
|
740
|
+
if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
|
|
741
|
+
};
|
|
742
|
+
/**
|
|
743
|
+
* Quickly scans a glob pattern and returns an object with a handful of
|
|
744
|
+
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
745
|
+
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
746
|
+
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
747
|
+
*
|
|
748
|
+
* ```js
|
|
749
|
+
* const pm = require('picomatch');
|
|
750
|
+
* console.log(pm.scan('foo/bar/*.js'));
|
|
751
|
+
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
752
|
+
* ```
|
|
753
|
+
* @param {String} `str`
|
|
754
|
+
* @param {Object} `options`
|
|
755
|
+
* @return {Object} Returns an object with tokens and regex source string.
|
|
756
|
+
* @api public
|
|
757
|
+
*/
|
|
758
|
+
const scan = (input, options) => {
|
|
759
|
+
const opts = options || {};
|
|
760
|
+
const length = input.length - 1;
|
|
761
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
762
|
+
const slashes = [];
|
|
763
|
+
const tokens = [];
|
|
764
|
+
const parts = [];
|
|
765
|
+
let str = input;
|
|
766
|
+
let index = -1;
|
|
767
|
+
let start = 0;
|
|
768
|
+
let lastIndex = 0;
|
|
769
|
+
let isBrace = false;
|
|
770
|
+
let isBracket = false;
|
|
771
|
+
let isGlob = false;
|
|
772
|
+
let isExtglob = false;
|
|
773
|
+
let isGlobstar = false;
|
|
774
|
+
let braceEscaped = false;
|
|
775
|
+
let backslashes = false;
|
|
776
|
+
let negated = false;
|
|
777
|
+
let negatedExtglob = false;
|
|
778
|
+
let finished = false;
|
|
779
|
+
let braces = 0;
|
|
780
|
+
let prev;
|
|
781
|
+
let code;
|
|
782
|
+
let token = {
|
|
783
|
+
value: "",
|
|
784
|
+
depth: 0,
|
|
785
|
+
isGlob: false
|
|
786
|
+
};
|
|
787
|
+
const eos = () => index >= length;
|
|
788
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
789
|
+
const advance = () => {
|
|
790
|
+
prev = code;
|
|
791
|
+
return str.charCodeAt(++index);
|
|
792
|
+
};
|
|
793
|
+
while (index < length) {
|
|
794
|
+
code = advance();
|
|
795
|
+
let next;
|
|
796
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
797
|
+
backslashes = token.backslashes = true;
|
|
798
|
+
code = advance();
|
|
799
|
+
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
803
|
+
braces++;
|
|
804
|
+
while (eos() !== true && (code = advance())) {
|
|
805
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
806
|
+
backslashes = token.backslashes = true;
|
|
807
|
+
advance();
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
811
|
+
braces++;
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
815
|
+
isBrace = token.isBrace = true;
|
|
816
|
+
isGlob = token.isGlob = true;
|
|
817
|
+
finished = true;
|
|
818
|
+
if (scanToEnd === true) continue;
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
822
|
+
isBrace = token.isBrace = true;
|
|
823
|
+
isGlob = token.isGlob = true;
|
|
824
|
+
finished = true;
|
|
825
|
+
if (scanToEnd === true) continue;
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
828
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
829
|
+
braces--;
|
|
830
|
+
if (braces === 0) {
|
|
831
|
+
braceEscaped = false;
|
|
832
|
+
isBrace = token.isBrace = true;
|
|
833
|
+
finished = true;
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
if (scanToEnd === true) continue;
|
|
839
|
+
break;
|
|
840
|
+
}
|
|
841
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
842
|
+
slashes.push(index);
|
|
843
|
+
tokens.push(token);
|
|
844
|
+
token = {
|
|
845
|
+
value: "",
|
|
846
|
+
depth: 0,
|
|
847
|
+
isGlob: false
|
|
848
|
+
};
|
|
849
|
+
if (finished === true) continue;
|
|
850
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
851
|
+
start += 2;
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
lastIndex = index + 1;
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
if (opts.noext !== true) {
|
|
858
|
+
if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
859
|
+
isGlob = token.isGlob = true;
|
|
860
|
+
isExtglob = token.isExtglob = true;
|
|
861
|
+
finished = true;
|
|
862
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
863
|
+
if (scanToEnd === true) {
|
|
864
|
+
while (eos() !== true && (code = advance())) {
|
|
865
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
866
|
+
backslashes = token.backslashes = true;
|
|
867
|
+
code = advance();
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
871
|
+
isGlob = token.isGlob = true;
|
|
872
|
+
finished = true;
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
break;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
if (code === CHAR_ASTERISK) {
|
|
882
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
883
|
+
isGlob = token.isGlob = true;
|
|
884
|
+
finished = true;
|
|
885
|
+
if (scanToEnd === true) continue;
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
889
|
+
isGlob = token.isGlob = true;
|
|
890
|
+
finished = true;
|
|
891
|
+
if (scanToEnd === true) continue;
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
895
|
+
while (eos() !== true && (next = advance())) {
|
|
896
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
897
|
+
backslashes = token.backslashes = true;
|
|
898
|
+
advance();
|
|
899
|
+
continue;
|
|
900
|
+
}
|
|
901
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
902
|
+
isBracket = token.isBracket = true;
|
|
903
|
+
isGlob = token.isGlob = true;
|
|
904
|
+
finished = true;
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
if (scanToEnd === true) continue;
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
912
|
+
negated = token.negated = true;
|
|
913
|
+
start++;
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
916
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
917
|
+
isGlob = token.isGlob = true;
|
|
918
|
+
if (scanToEnd === true) {
|
|
919
|
+
while (eos() !== true && (code = advance())) {
|
|
920
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
921
|
+
backslashes = token.backslashes = true;
|
|
922
|
+
code = advance();
|
|
923
|
+
continue;
|
|
924
|
+
}
|
|
925
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
926
|
+
finished = true;
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
continue;
|
|
931
|
+
}
|
|
932
|
+
break;
|
|
933
|
+
}
|
|
934
|
+
if (isGlob === true) {
|
|
935
|
+
finished = true;
|
|
936
|
+
if (scanToEnd === true) continue;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
if (opts.noext === true) {
|
|
941
|
+
isExtglob = false;
|
|
942
|
+
isGlob = false;
|
|
943
|
+
}
|
|
944
|
+
let base = str;
|
|
945
|
+
let prefix = "";
|
|
946
|
+
let glob = "";
|
|
947
|
+
if (start > 0) {
|
|
948
|
+
prefix = str.slice(0, start);
|
|
949
|
+
str = str.slice(start);
|
|
950
|
+
lastIndex -= start;
|
|
951
|
+
}
|
|
952
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
953
|
+
base = str.slice(0, lastIndex);
|
|
954
|
+
glob = str.slice(lastIndex);
|
|
955
|
+
} else if (isGlob === true) {
|
|
956
|
+
base = "";
|
|
957
|
+
glob = str;
|
|
958
|
+
} else base = str;
|
|
959
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
960
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
961
|
+
}
|
|
962
|
+
if (opts.unescape === true) {
|
|
963
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
964
|
+
if (base && backslashes === true) base = utils.removeBackslashes(base);
|
|
965
|
+
}
|
|
966
|
+
const state = {
|
|
967
|
+
prefix,
|
|
968
|
+
input,
|
|
969
|
+
start,
|
|
970
|
+
base,
|
|
971
|
+
glob,
|
|
972
|
+
isBrace,
|
|
973
|
+
isBracket,
|
|
974
|
+
isGlob,
|
|
975
|
+
isExtglob,
|
|
976
|
+
isGlobstar,
|
|
977
|
+
negated,
|
|
978
|
+
negatedExtglob
|
|
979
|
+
};
|
|
980
|
+
if (opts.tokens === true) {
|
|
981
|
+
state.maxDepth = 0;
|
|
982
|
+
if (!isPathSeparator(code)) tokens.push(token);
|
|
983
|
+
state.tokens = tokens;
|
|
984
|
+
}
|
|
985
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
986
|
+
let prevIndex;
|
|
987
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
988
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
989
|
+
const i = slashes[idx];
|
|
990
|
+
const value = input.slice(n, i);
|
|
991
|
+
if (opts.tokens) {
|
|
992
|
+
if (idx === 0 && start !== 0) {
|
|
993
|
+
tokens[idx].isPrefix = true;
|
|
994
|
+
tokens[idx].value = prefix;
|
|
995
|
+
} else tokens[idx].value = value;
|
|
996
|
+
depth(tokens[idx]);
|
|
997
|
+
state.maxDepth += tokens[idx].depth;
|
|
998
|
+
}
|
|
999
|
+
if (idx !== 0 || value !== "") parts.push(value);
|
|
1000
|
+
prevIndex = i;
|
|
1001
|
+
}
|
|
1002
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1003
|
+
const value = input.slice(prevIndex + 1);
|
|
1004
|
+
parts.push(value);
|
|
1005
|
+
if (opts.tokens) {
|
|
1006
|
+
tokens[tokens.length - 1].value = value;
|
|
1007
|
+
depth(tokens[tokens.length - 1]);
|
|
1008
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
state.slashes = slashes;
|
|
1012
|
+
state.parts = parts;
|
|
1013
|
+
}
|
|
1014
|
+
return state;
|
|
1015
|
+
};
|
|
1016
|
+
module.exports = scan;
|
|
1017
|
+
}));
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js
|
|
1020
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1021
|
+
const constants = require_constants();
|
|
1022
|
+
const utils = require_utils();
|
|
1023
|
+
/**
|
|
1024
|
+
* Constants
|
|
1025
|
+
*/
|
|
1026
|
+
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
1027
|
+
/**
|
|
1028
|
+
* Helpers
|
|
1029
|
+
*/
|
|
1030
|
+
const expandRange = (args, options) => {
|
|
1031
|
+
if (typeof options.expandRange === "function") return options.expandRange(...args, options);
|
|
1032
|
+
args.sort();
|
|
1033
|
+
const value = `[${args.join("-")}]`;
|
|
1034
|
+
try {
|
|
1035
|
+
new RegExp(value);
|
|
1036
|
+
} catch (ex) {
|
|
1037
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
1038
|
+
}
|
|
1039
|
+
return value;
|
|
1040
|
+
};
|
|
1041
|
+
/**
|
|
1042
|
+
* Create the message for a syntax error
|
|
1043
|
+
*/
|
|
1044
|
+
const syntaxError = (type, char) => {
|
|
1045
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
1046
|
+
};
|
|
1047
|
+
const splitTopLevel = (input) => {
|
|
1048
|
+
const parts = [];
|
|
1049
|
+
let bracket = 0;
|
|
1050
|
+
let paren = 0;
|
|
1051
|
+
let quote = 0;
|
|
1052
|
+
let value = "";
|
|
1053
|
+
let escaped = false;
|
|
1054
|
+
for (const ch of input) {
|
|
1055
|
+
if (escaped === true) {
|
|
1056
|
+
value += ch;
|
|
1057
|
+
escaped = false;
|
|
1058
|
+
continue;
|
|
1059
|
+
}
|
|
1060
|
+
if (ch === "\\") {
|
|
1061
|
+
value += ch;
|
|
1062
|
+
escaped = true;
|
|
1063
|
+
continue;
|
|
1064
|
+
}
|
|
1065
|
+
if (ch === "\"") {
|
|
1066
|
+
quote = quote === 1 ? 0 : 1;
|
|
1067
|
+
value += ch;
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
if (quote === 0) {
|
|
1071
|
+
if (ch === "[") bracket++;
|
|
1072
|
+
else if (ch === "]" && bracket > 0) bracket--;
|
|
1073
|
+
else if (bracket === 0) {
|
|
1074
|
+
if (ch === "(") paren++;
|
|
1075
|
+
else if (ch === ")" && paren > 0) paren--;
|
|
1076
|
+
else if (ch === "|" && paren === 0) {
|
|
1077
|
+
parts.push(value);
|
|
1078
|
+
value = "";
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
value += ch;
|
|
1084
|
+
}
|
|
1085
|
+
parts.push(value);
|
|
1086
|
+
return parts;
|
|
1087
|
+
};
|
|
1088
|
+
const isPlainBranch = (branch) => {
|
|
1089
|
+
let escaped = false;
|
|
1090
|
+
for (const ch of branch) {
|
|
1091
|
+
if (escaped === true) {
|
|
1092
|
+
escaped = false;
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
if (ch === "\\") {
|
|
1096
|
+
escaped = true;
|
|
1097
|
+
continue;
|
|
1098
|
+
}
|
|
1099
|
+
if (/[?*+@!()[\]{}]/.test(ch)) return false;
|
|
1100
|
+
}
|
|
1101
|
+
return true;
|
|
1102
|
+
};
|
|
1103
|
+
const normalizeSimpleBranch = (branch) => {
|
|
1104
|
+
let value = branch.trim();
|
|
1105
|
+
let changed = true;
|
|
1106
|
+
while (changed === true) {
|
|
1107
|
+
changed = false;
|
|
1108
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
1109
|
+
value = value.slice(2, -1);
|
|
1110
|
+
changed = true;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
if (!isPlainBranch(value)) return;
|
|
1114
|
+
return value.replace(/\\(.)/g, "$1");
|
|
1115
|
+
};
|
|
1116
|
+
const hasRepeatedCharPrefixOverlap = (branches) => {
|
|
1117
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
1118
|
+
for (let i = 0; i < values.length; i++) for (let j = i + 1; j < values.length; j++) {
|
|
1119
|
+
const a = values[i];
|
|
1120
|
+
const b = values[j];
|
|
1121
|
+
const char = a[0];
|
|
1122
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) continue;
|
|
1123
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) return true;
|
|
1124
|
+
}
|
|
1125
|
+
return false;
|
|
1126
|
+
};
|
|
1127
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
1128
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") return;
|
|
1129
|
+
let bracket = 0;
|
|
1130
|
+
let paren = 0;
|
|
1131
|
+
let quote = 0;
|
|
1132
|
+
let escaped = false;
|
|
1133
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
1134
|
+
const ch = pattern[i];
|
|
1135
|
+
if (escaped === true) {
|
|
1136
|
+
escaped = false;
|
|
1137
|
+
continue;
|
|
1138
|
+
}
|
|
1139
|
+
if (ch === "\\") {
|
|
1140
|
+
escaped = true;
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
if (ch === "\"") {
|
|
1144
|
+
quote = quote === 1 ? 0 : 1;
|
|
1145
|
+
continue;
|
|
1146
|
+
}
|
|
1147
|
+
if (quote === 1) continue;
|
|
1148
|
+
if (ch === "[") {
|
|
1149
|
+
bracket++;
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
if (ch === "]" && bracket > 0) {
|
|
1153
|
+
bracket--;
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
if (bracket > 0) continue;
|
|
1157
|
+
if (ch === "(") {
|
|
1158
|
+
paren++;
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
if (ch === ")") {
|
|
1162
|
+
paren--;
|
|
1163
|
+
if (paren === 0) {
|
|
1164
|
+
if (requireEnd === true && i !== pattern.length - 1) return;
|
|
1165
|
+
return {
|
|
1166
|
+
type: pattern[0],
|
|
1167
|
+
body: pattern.slice(2, i),
|
|
1168
|
+
end: i
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
const getStarExtglobSequenceOutput = (pattern) => {
|
|
1175
|
+
let index = 0;
|
|
1176
|
+
const chars = [];
|
|
1177
|
+
while (index < pattern.length) {
|
|
1178
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
1179
|
+
if (!match || match.type !== "*") return;
|
|
1180
|
+
const branches = splitTopLevel(match.body).map((branch) => branch.trim());
|
|
1181
|
+
if (branches.length !== 1) return;
|
|
1182
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
1183
|
+
if (!branch || branch.length !== 1) return;
|
|
1184
|
+
chars.push(branch);
|
|
1185
|
+
index += match.end + 1;
|
|
1186
|
+
}
|
|
1187
|
+
if (chars.length < 1) return;
|
|
1188
|
+
return `${chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`}*`;
|
|
1189
|
+
};
|
|
1190
|
+
const repeatedExtglobRecursion = (pattern) => {
|
|
1191
|
+
let depth = 0;
|
|
1192
|
+
let value = pattern.trim();
|
|
1193
|
+
let match = parseRepeatedExtglob(value);
|
|
1194
|
+
while (match) {
|
|
1195
|
+
depth++;
|
|
1196
|
+
value = match.body.trim();
|
|
1197
|
+
match = parseRepeatedExtglob(value);
|
|
1198
|
+
}
|
|
1199
|
+
return depth;
|
|
1200
|
+
};
|
|
1201
|
+
const analyzeRepeatedExtglob = (body, options) => {
|
|
1202
|
+
if (options.maxExtglobRecursion === false) return { risky: false };
|
|
1203
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
1204
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
1205
|
+
if (branches.length > 1) {
|
|
1206
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return { risky: true };
|
|
1207
|
+
}
|
|
1208
|
+
for (const branch of branches) {
|
|
1209
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
1210
|
+
if (safeOutput) return {
|
|
1211
|
+
risky: true,
|
|
1212
|
+
safeOutput
|
|
1213
|
+
};
|
|
1214
|
+
if (repeatedExtglobRecursion(branch) > max) return { risky: true };
|
|
1215
|
+
}
|
|
1216
|
+
return { risky: false };
|
|
1217
|
+
};
|
|
1218
|
+
/**
|
|
1219
|
+
* Parse the given input string.
|
|
1220
|
+
* @param {String} input
|
|
1221
|
+
* @param {Object} options
|
|
1222
|
+
* @return {Object}
|
|
1223
|
+
*/
|
|
1224
|
+
const parse = (input, options) => {
|
|
1225
|
+
if (typeof input !== "string") throw new TypeError("Expected a string");
|
|
1226
|
+
input = REPLACEMENTS[input] || input;
|
|
1227
|
+
const opts = { ...options };
|
|
1228
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1229
|
+
let len = input.length;
|
|
1230
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1231
|
+
const bos = {
|
|
1232
|
+
type: "bos",
|
|
1233
|
+
value: "",
|
|
1234
|
+
output: opts.prepend || ""
|
|
1235
|
+
};
|
|
1236
|
+
const tokens = [bos];
|
|
1237
|
+
const capture = opts.capture ? "" : "?:";
|
|
1238
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
1239
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
1240
|
+
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
|
|
1241
|
+
const globstar = (opts) => {
|
|
1242
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1243
|
+
};
|
|
1244
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
1245
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
1246
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
1247
|
+
if (opts.capture) star = `(${star})`;
|
|
1248
|
+
if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
|
|
1249
|
+
const state = {
|
|
1250
|
+
input,
|
|
1251
|
+
index: -1,
|
|
1252
|
+
start: 0,
|
|
1253
|
+
dot: opts.dot === true,
|
|
1254
|
+
consumed: "",
|
|
1255
|
+
output: "",
|
|
1256
|
+
prefix: "",
|
|
1257
|
+
backtrack: false,
|
|
1258
|
+
negated: false,
|
|
1259
|
+
brackets: 0,
|
|
1260
|
+
braces: 0,
|
|
1261
|
+
parens: 0,
|
|
1262
|
+
quotes: 0,
|
|
1263
|
+
globstar: false,
|
|
1264
|
+
tokens
|
|
1265
|
+
};
|
|
1266
|
+
input = utils.removePrefix(input, state);
|
|
1267
|
+
len = input.length;
|
|
1268
|
+
const extglobs = [];
|
|
1269
|
+
const braces = [];
|
|
1270
|
+
const stack = [];
|
|
1271
|
+
let prev = bos;
|
|
1272
|
+
let value;
|
|
1273
|
+
/**
|
|
1274
|
+
* Tokenizing helpers
|
|
1275
|
+
*/
|
|
1276
|
+
const eos = () => state.index === len - 1;
|
|
1277
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1278
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
1279
|
+
const remaining = () => input.slice(state.index + 1);
|
|
1280
|
+
const consume = (value = "", num = 0) => {
|
|
1281
|
+
state.consumed += value;
|
|
1282
|
+
state.index += num;
|
|
1283
|
+
};
|
|
1284
|
+
const append = (token) => {
|
|
1285
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1286
|
+
consume(token.value);
|
|
1287
|
+
};
|
|
1288
|
+
const negate = () => {
|
|
1289
|
+
let count = 1;
|
|
1290
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
1291
|
+
advance();
|
|
1292
|
+
state.start++;
|
|
1293
|
+
count++;
|
|
1294
|
+
}
|
|
1295
|
+
if (count % 2 === 0) return false;
|
|
1296
|
+
state.negated = true;
|
|
1297
|
+
state.start++;
|
|
1298
|
+
return true;
|
|
1299
|
+
};
|
|
1300
|
+
const increment = (type) => {
|
|
1301
|
+
state[type]++;
|
|
1302
|
+
stack.push(type);
|
|
1303
|
+
};
|
|
1304
|
+
const decrement = (type) => {
|
|
1305
|
+
state[type]--;
|
|
1306
|
+
stack.pop();
|
|
1307
|
+
};
|
|
1308
|
+
/**
|
|
1309
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
1310
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
1311
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
1312
|
+
* characters are plain text. This improves performance and simplifies
|
|
1313
|
+
* lookbehinds.
|
|
1314
|
+
*/
|
|
1315
|
+
const push = (tok) => {
|
|
1316
|
+
if (prev.type === "globstar") {
|
|
1317
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
1318
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
1319
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
1320
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1321
|
+
prev.type = "star";
|
|
1322
|
+
prev.value = "*";
|
|
1323
|
+
prev.output = star;
|
|
1324
|
+
state.output += prev.output;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
|
|
1328
|
+
if (tok.value || tok.output) append(tok);
|
|
1329
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
1330
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
1331
|
+
prev.value += tok.value;
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
tok.prev = prev;
|
|
1335
|
+
tokens.push(tok);
|
|
1336
|
+
prev = tok;
|
|
1337
|
+
};
|
|
1338
|
+
const extglobOpen = (type, value) => {
|
|
1339
|
+
const token = {
|
|
1340
|
+
...EXTGLOB_CHARS[value],
|
|
1341
|
+
conditions: 1,
|
|
1342
|
+
inner: ""
|
|
1343
|
+
};
|
|
1344
|
+
token.prev = prev;
|
|
1345
|
+
token.parens = state.parens;
|
|
1346
|
+
token.output = state.output;
|
|
1347
|
+
token.startIndex = state.index;
|
|
1348
|
+
token.tokensIndex = tokens.length;
|
|
1349
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
1350
|
+
increment("parens");
|
|
1351
|
+
push({
|
|
1352
|
+
type,
|
|
1353
|
+
value,
|
|
1354
|
+
output: state.output ? "" : ONE_CHAR
|
|
1355
|
+
});
|
|
1356
|
+
push({
|
|
1357
|
+
type: "paren",
|
|
1358
|
+
extglob: true,
|
|
1359
|
+
value: advance(),
|
|
1360
|
+
output
|
|
1361
|
+
});
|
|
1362
|
+
extglobs.push(token);
|
|
1363
|
+
};
|
|
1364
|
+
const extglobClose = (token) => {
|
|
1365
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
1366
|
+
const analysis = analyzeRepeatedExtglob(input.slice(token.startIndex + 2, state.index), opts);
|
|
1367
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
1368
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
1369
|
+
const open = tokens[token.tokensIndex];
|
|
1370
|
+
open.type = "text";
|
|
1371
|
+
open.value = literal;
|
|
1372
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
1373
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
1374
|
+
tokens[i].value = "";
|
|
1375
|
+
tokens[i].output = "";
|
|
1376
|
+
delete tokens[i].suffix;
|
|
1377
|
+
}
|
|
1378
|
+
state.output = token.output + open.output;
|
|
1379
|
+
state.backtrack = true;
|
|
1380
|
+
push({
|
|
1381
|
+
type: "paren",
|
|
1382
|
+
extglob: true,
|
|
1383
|
+
value,
|
|
1384
|
+
output: ""
|
|
1385
|
+
});
|
|
1386
|
+
decrement("parens");
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
1390
|
+
let rest;
|
|
1391
|
+
if (token.type === "negate") {
|
|
1392
|
+
let extglobStar = star;
|
|
1393
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
|
|
1394
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
1395
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse(rest, {
|
|
1396
|
+
...options,
|
|
1397
|
+
fastpaths: false
|
|
1398
|
+
}).output})${extglobStar})`;
|
|
1399
|
+
if (token.prev.type === "bos") state.negatedExtglob = true;
|
|
1400
|
+
}
|
|
1401
|
+
push({
|
|
1402
|
+
type: "paren",
|
|
1403
|
+
extglob: true,
|
|
1404
|
+
value,
|
|
1405
|
+
output
|
|
1406
|
+
});
|
|
1407
|
+
decrement("parens");
|
|
1408
|
+
};
|
|
1409
|
+
/**
|
|
1410
|
+
* Fast paths
|
|
1411
|
+
*/
|
|
1412
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1413
|
+
let backslashes = false;
|
|
1414
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1415
|
+
if (first === "\\") {
|
|
1416
|
+
backslashes = true;
|
|
1417
|
+
return m;
|
|
1418
|
+
}
|
|
1419
|
+
if (first === "?") {
|
|
1420
|
+
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
1421
|
+
if (index === 0) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
1422
|
+
return QMARK.repeat(chars.length);
|
|
1423
|
+
}
|
|
1424
|
+
if (first === ".") return DOT_LITERAL.repeat(chars.length);
|
|
1425
|
+
if (first === "*") {
|
|
1426
|
+
if (esc) return esc + first + (rest ? star : "");
|
|
1427
|
+
return star;
|
|
1428
|
+
}
|
|
1429
|
+
return esc ? m : `\\${m}`;
|
|
1430
|
+
});
|
|
1431
|
+
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
|
|
1432
|
+
else output = output.replace(/\\+/g, (m) => {
|
|
1433
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1434
|
+
});
|
|
1435
|
+
if (output === input && opts.contains === true) {
|
|
1436
|
+
state.output = input;
|
|
1437
|
+
return state;
|
|
1438
|
+
}
|
|
1439
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
1440
|
+
return state;
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Tokenize input until we reach end-of-string
|
|
1444
|
+
*/
|
|
1445
|
+
while (!eos()) {
|
|
1446
|
+
value = advance();
|
|
1447
|
+
if (value === "\0") continue;
|
|
1448
|
+
/**
|
|
1449
|
+
* Escaped characters
|
|
1450
|
+
*/
|
|
1451
|
+
if (value === "\\") {
|
|
1452
|
+
const next = peek();
|
|
1453
|
+
if (next === "/" && opts.bash !== true) continue;
|
|
1454
|
+
if (next === "." || next === ";") continue;
|
|
1455
|
+
if (!next) {
|
|
1456
|
+
value += "\\";
|
|
1457
|
+
push({
|
|
1458
|
+
type: "text",
|
|
1459
|
+
value
|
|
1460
|
+
});
|
|
1461
|
+
continue;
|
|
1462
|
+
}
|
|
1463
|
+
const match = /^\\+/.exec(remaining());
|
|
1464
|
+
let slashes = 0;
|
|
1465
|
+
if (match && match[0].length > 2) {
|
|
1466
|
+
slashes = match[0].length;
|
|
1467
|
+
state.index += slashes;
|
|
1468
|
+
if (slashes % 2 !== 0) value += "\\";
|
|
1469
|
+
}
|
|
1470
|
+
if (opts.unescape === true) value = advance();
|
|
1471
|
+
else value += advance();
|
|
1472
|
+
if (state.brackets === 0) {
|
|
1473
|
+
push({
|
|
1474
|
+
type: "text",
|
|
1475
|
+
value
|
|
1476
|
+
});
|
|
1477
|
+
continue;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* If we're inside a regex character class, continue
|
|
1482
|
+
* until we reach the closing bracket.
|
|
1483
|
+
*/
|
|
1484
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1485
|
+
if (opts.posix !== false && value === ":") {
|
|
1486
|
+
const inner = prev.value.slice(1);
|
|
1487
|
+
if (inner.includes("[")) {
|
|
1488
|
+
prev.posix = true;
|
|
1489
|
+
if (inner.includes(":")) {
|
|
1490
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1491
|
+
const pre = prev.value.slice(0, idx);
|
|
1492
|
+
const posix = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
|
|
1493
|
+
if (posix) {
|
|
1494
|
+
prev.value = pre + posix;
|
|
1495
|
+
state.backtrack = true;
|
|
1496
|
+
advance();
|
|
1497
|
+
if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR;
|
|
1498
|
+
continue;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
|
|
1504
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
|
|
1505
|
+
if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
|
|
1506
|
+
prev.value += value;
|
|
1507
|
+
append({ value });
|
|
1508
|
+
continue;
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* If we're inside a quoted string, continue
|
|
1512
|
+
* until we reach the closing double quote.
|
|
1513
|
+
*/
|
|
1514
|
+
if (state.quotes === 1 && value !== "\"") {
|
|
1515
|
+
value = utils.escapeRegex(value);
|
|
1516
|
+
prev.value += value;
|
|
1517
|
+
append({ value });
|
|
1518
|
+
continue;
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Double quotes
|
|
1522
|
+
*/
|
|
1523
|
+
if (value === "\"") {
|
|
1524
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1525
|
+
if (opts.keepQuotes === true) push({
|
|
1526
|
+
type: "text",
|
|
1527
|
+
value
|
|
1528
|
+
});
|
|
1529
|
+
continue;
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Parentheses
|
|
1533
|
+
*/
|
|
1534
|
+
if (value === "(") {
|
|
1535
|
+
increment("parens");
|
|
1536
|
+
push({
|
|
1537
|
+
type: "paren",
|
|
1538
|
+
value
|
|
1539
|
+
});
|
|
1540
|
+
continue;
|
|
1541
|
+
}
|
|
1542
|
+
if (value === ")") {
|
|
1543
|
+
if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
|
|
1544
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1545
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1546
|
+
extglobClose(extglobs.pop());
|
|
1547
|
+
continue;
|
|
1548
|
+
}
|
|
1549
|
+
push({
|
|
1550
|
+
type: "paren",
|
|
1551
|
+
value,
|
|
1552
|
+
output: state.parens ? ")" : "\\)"
|
|
1553
|
+
});
|
|
1554
|
+
decrement("parens");
|
|
1555
|
+
continue;
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* Square brackets
|
|
1559
|
+
*/
|
|
1560
|
+
if (value === "[") {
|
|
1561
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1562
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1563
|
+
value = `\\${value}`;
|
|
1564
|
+
} else increment("brackets");
|
|
1565
|
+
push({
|
|
1566
|
+
type: "bracket",
|
|
1567
|
+
value
|
|
1568
|
+
});
|
|
1569
|
+
continue;
|
|
1570
|
+
}
|
|
1571
|
+
if (value === "]") {
|
|
1572
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1573
|
+
push({
|
|
1574
|
+
type: "text",
|
|
1575
|
+
value,
|
|
1576
|
+
output: `\\${value}`
|
|
1577
|
+
});
|
|
1578
|
+
continue;
|
|
1579
|
+
}
|
|
1580
|
+
if (state.brackets === 0) {
|
|
1581
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
|
|
1582
|
+
push({
|
|
1583
|
+
type: "text",
|
|
1584
|
+
value,
|
|
1585
|
+
output: `\\${value}`
|
|
1586
|
+
});
|
|
1587
|
+
continue;
|
|
1588
|
+
}
|
|
1589
|
+
decrement("brackets");
|
|
1590
|
+
const prevValue = prev.value.slice(1);
|
|
1591
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
|
|
1592
|
+
prev.value += value;
|
|
1593
|
+
append({ value });
|
|
1594
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) continue;
|
|
1595
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1596
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1597
|
+
if (opts.literalBrackets === true) {
|
|
1598
|
+
state.output += escaped;
|
|
1599
|
+
prev.value = escaped;
|
|
1600
|
+
continue;
|
|
1601
|
+
}
|
|
1602
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1603
|
+
state.output += prev.value;
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Braces
|
|
1608
|
+
*/
|
|
1609
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1610
|
+
increment("braces");
|
|
1611
|
+
const open = {
|
|
1612
|
+
type: "brace",
|
|
1613
|
+
value,
|
|
1614
|
+
output: "(",
|
|
1615
|
+
outputIndex: state.output.length,
|
|
1616
|
+
tokensIndex: state.tokens.length
|
|
1617
|
+
};
|
|
1618
|
+
braces.push(open);
|
|
1619
|
+
push(open);
|
|
1620
|
+
continue;
|
|
1621
|
+
}
|
|
1622
|
+
if (value === "}") {
|
|
1623
|
+
const brace = braces[braces.length - 1];
|
|
1624
|
+
if (opts.nobrace === true || !brace) {
|
|
1625
|
+
push({
|
|
1626
|
+
type: "text",
|
|
1627
|
+
value,
|
|
1628
|
+
output: value
|
|
1629
|
+
});
|
|
1630
|
+
continue;
|
|
1631
|
+
}
|
|
1632
|
+
let output = ")";
|
|
1633
|
+
if (brace.dots === true) {
|
|
1634
|
+
const arr = tokens.slice();
|
|
1635
|
+
const range = [];
|
|
1636
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1637
|
+
tokens.pop();
|
|
1638
|
+
if (arr[i].type === "brace") break;
|
|
1639
|
+
if (arr[i].type !== "dots") range.unshift(arr[i].value);
|
|
1640
|
+
}
|
|
1641
|
+
output = expandRange(range, opts);
|
|
1642
|
+
state.backtrack = true;
|
|
1643
|
+
}
|
|
1644
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1645
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1646
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1647
|
+
brace.value = brace.output = "\\{";
|
|
1648
|
+
value = output = "\\}";
|
|
1649
|
+
state.output = out;
|
|
1650
|
+
for (const t of toks) state.output += t.output || t.value;
|
|
1651
|
+
}
|
|
1652
|
+
push({
|
|
1653
|
+
type: "brace",
|
|
1654
|
+
value,
|
|
1655
|
+
output
|
|
1656
|
+
});
|
|
1657
|
+
decrement("braces");
|
|
1658
|
+
braces.pop();
|
|
1659
|
+
continue;
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Pipes
|
|
1663
|
+
*/
|
|
1664
|
+
if (value === "|") {
|
|
1665
|
+
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
1666
|
+
push({
|
|
1667
|
+
type: "text",
|
|
1668
|
+
value
|
|
1669
|
+
});
|
|
1670
|
+
continue;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* Commas
|
|
1674
|
+
*/
|
|
1675
|
+
if (value === ",") {
|
|
1676
|
+
let output = value;
|
|
1677
|
+
const brace = braces[braces.length - 1];
|
|
1678
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1679
|
+
brace.comma = true;
|
|
1680
|
+
output = "|";
|
|
1681
|
+
}
|
|
1682
|
+
push({
|
|
1683
|
+
type: "comma",
|
|
1684
|
+
value,
|
|
1685
|
+
output
|
|
1686
|
+
});
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
/**
|
|
1690
|
+
* Slashes
|
|
1691
|
+
*/
|
|
1692
|
+
if (value === "/") {
|
|
1693
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1694
|
+
state.start = state.index + 1;
|
|
1695
|
+
state.consumed = "";
|
|
1696
|
+
state.output = "";
|
|
1697
|
+
tokens.pop();
|
|
1698
|
+
prev = bos;
|
|
1699
|
+
continue;
|
|
1700
|
+
}
|
|
1701
|
+
push({
|
|
1702
|
+
type: "slash",
|
|
1703
|
+
value,
|
|
1704
|
+
output: SLASH_LITERAL
|
|
1705
|
+
});
|
|
1706
|
+
continue;
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Dots
|
|
1710
|
+
*/
|
|
1711
|
+
if (value === ".") {
|
|
1712
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1713
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1714
|
+
const brace = braces[braces.length - 1];
|
|
1715
|
+
prev.type = "dots";
|
|
1716
|
+
prev.output += value;
|
|
1717
|
+
prev.value += value;
|
|
1718
|
+
brace.dots = true;
|
|
1719
|
+
continue;
|
|
1720
|
+
}
|
|
1721
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1722
|
+
push({
|
|
1723
|
+
type: "text",
|
|
1724
|
+
value,
|
|
1725
|
+
output: DOT_LITERAL
|
|
1726
|
+
});
|
|
1727
|
+
continue;
|
|
1728
|
+
}
|
|
1729
|
+
push({
|
|
1730
|
+
type: "dot",
|
|
1731
|
+
value,
|
|
1732
|
+
output: DOT_LITERAL
|
|
1733
|
+
});
|
|
1734
|
+
continue;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Question marks
|
|
1738
|
+
*/
|
|
1739
|
+
if (value === "?") {
|
|
1740
|
+
if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1741
|
+
extglobOpen("qmark", value);
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
if (prev && prev.type === "paren") {
|
|
1745
|
+
const next = peek();
|
|
1746
|
+
let output = value;
|
|
1747
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
1748
|
+
push({
|
|
1749
|
+
type: "text",
|
|
1750
|
+
value,
|
|
1751
|
+
output
|
|
1752
|
+
});
|
|
1753
|
+
continue;
|
|
1754
|
+
}
|
|
1755
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1756
|
+
push({
|
|
1757
|
+
type: "qmark",
|
|
1758
|
+
value,
|
|
1759
|
+
output: QMARK_NO_DOT
|
|
1760
|
+
});
|
|
1761
|
+
continue;
|
|
1762
|
+
}
|
|
1763
|
+
push({
|
|
1764
|
+
type: "qmark",
|
|
1765
|
+
value,
|
|
1766
|
+
output: QMARK
|
|
1767
|
+
});
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Exclamation
|
|
1772
|
+
*/
|
|
1773
|
+
if (value === "!") {
|
|
1774
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1775
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1776
|
+
extglobOpen("negate", value);
|
|
1777
|
+
continue;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1781
|
+
negate();
|
|
1782
|
+
continue;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
/**
|
|
1786
|
+
* Plus
|
|
1787
|
+
*/
|
|
1788
|
+
if (value === "+") {
|
|
1789
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1790
|
+
extglobOpen("plus", value);
|
|
1791
|
+
continue;
|
|
1792
|
+
}
|
|
1793
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1794
|
+
push({
|
|
1795
|
+
type: "plus",
|
|
1796
|
+
value,
|
|
1797
|
+
output: PLUS_LITERAL
|
|
1798
|
+
});
|
|
1799
|
+
continue;
|
|
1800
|
+
}
|
|
1801
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1802
|
+
push({
|
|
1803
|
+
type: "plus",
|
|
1804
|
+
value
|
|
1805
|
+
});
|
|
1806
|
+
continue;
|
|
1807
|
+
}
|
|
1808
|
+
push({
|
|
1809
|
+
type: "plus",
|
|
1810
|
+
value: PLUS_LITERAL
|
|
1811
|
+
});
|
|
1812
|
+
continue;
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Plain text
|
|
1816
|
+
*/
|
|
1817
|
+
if (value === "@") {
|
|
1818
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1819
|
+
push({
|
|
1820
|
+
type: "at",
|
|
1821
|
+
extglob: true,
|
|
1822
|
+
value,
|
|
1823
|
+
output: ""
|
|
1824
|
+
});
|
|
1825
|
+
continue;
|
|
1826
|
+
}
|
|
1827
|
+
push({
|
|
1828
|
+
type: "text",
|
|
1829
|
+
value
|
|
1830
|
+
});
|
|
1831
|
+
continue;
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Plain text
|
|
1835
|
+
*/
|
|
1836
|
+
if (value !== "*") {
|
|
1837
|
+
if (value === "$" || value === "^") value = `\\${value}`;
|
|
1838
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1839
|
+
if (match) {
|
|
1840
|
+
value += match[0];
|
|
1841
|
+
state.index += match[0].length;
|
|
1842
|
+
}
|
|
1843
|
+
push({
|
|
1844
|
+
type: "text",
|
|
1845
|
+
value
|
|
1846
|
+
});
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Stars
|
|
1851
|
+
*/
|
|
1852
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1853
|
+
prev.type = "star";
|
|
1854
|
+
prev.star = true;
|
|
1855
|
+
prev.value += value;
|
|
1856
|
+
prev.output = star;
|
|
1857
|
+
state.backtrack = true;
|
|
1858
|
+
state.globstar = true;
|
|
1859
|
+
consume(value);
|
|
1860
|
+
continue;
|
|
1861
|
+
}
|
|
1862
|
+
let rest = remaining();
|
|
1863
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1864
|
+
extglobOpen("star", value);
|
|
1865
|
+
continue;
|
|
1866
|
+
}
|
|
1867
|
+
if (prev.type === "star") {
|
|
1868
|
+
if (opts.noglobstar === true) {
|
|
1869
|
+
consume(value);
|
|
1870
|
+
continue;
|
|
1871
|
+
}
|
|
1872
|
+
const prior = prev.prev;
|
|
1873
|
+
const before = prior.prev;
|
|
1874
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1875
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1876
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1877
|
+
push({
|
|
1878
|
+
type: "star",
|
|
1879
|
+
value,
|
|
1880
|
+
output: ""
|
|
1881
|
+
});
|
|
1882
|
+
continue;
|
|
1883
|
+
}
|
|
1884
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1885
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1886
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1887
|
+
push({
|
|
1888
|
+
type: "star",
|
|
1889
|
+
value,
|
|
1890
|
+
output: ""
|
|
1891
|
+
});
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1895
|
+
const after = input[state.index + 4];
|
|
1896
|
+
if (after && after !== "/") break;
|
|
1897
|
+
rest = rest.slice(3);
|
|
1898
|
+
consume("/**", 3);
|
|
1899
|
+
}
|
|
1900
|
+
if (prior.type === "bos" && eos()) {
|
|
1901
|
+
prev.type = "globstar";
|
|
1902
|
+
prev.value += value;
|
|
1903
|
+
prev.output = globstar(opts);
|
|
1904
|
+
state.output = prev.output;
|
|
1905
|
+
state.globstar = true;
|
|
1906
|
+
consume(value);
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1910
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1911
|
+
prior.output = `(?:${prior.output}`;
|
|
1912
|
+
prev.type = "globstar";
|
|
1913
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1914
|
+
prev.value += value;
|
|
1915
|
+
state.globstar = true;
|
|
1916
|
+
state.output += prior.output + prev.output;
|
|
1917
|
+
consume(value);
|
|
1918
|
+
continue;
|
|
1919
|
+
}
|
|
1920
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1921
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1922
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1923
|
+
prior.output = `(?:${prior.output}`;
|
|
1924
|
+
prev.type = "globstar";
|
|
1925
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1926
|
+
prev.value += value;
|
|
1927
|
+
state.output += prior.output + prev.output;
|
|
1928
|
+
state.globstar = true;
|
|
1929
|
+
consume(value + advance());
|
|
1930
|
+
push({
|
|
1931
|
+
type: "slash",
|
|
1932
|
+
value: "/",
|
|
1933
|
+
output: ""
|
|
1934
|
+
});
|
|
1935
|
+
continue;
|
|
1936
|
+
}
|
|
1937
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1938
|
+
prev.type = "globstar";
|
|
1939
|
+
prev.value += value;
|
|
1940
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1941
|
+
state.output = prev.output;
|
|
1942
|
+
state.globstar = true;
|
|
1943
|
+
consume(value + advance());
|
|
1944
|
+
push({
|
|
1945
|
+
type: "slash",
|
|
1946
|
+
value: "/",
|
|
1947
|
+
output: ""
|
|
1948
|
+
});
|
|
1949
|
+
continue;
|
|
1950
|
+
}
|
|
1951
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1952
|
+
prev.type = "globstar";
|
|
1953
|
+
prev.output = globstar(opts);
|
|
1954
|
+
prev.value += value;
|
|
1955
|
+
state.output += prev.output;
|
|
1956
|
+
state.globstar = true;
|
|
1957
|
+
consume(value);
|
|
1958
|
+
continue;
|
|
1959
|
+
}
|
|
1960
|
+
const token = {
|
|
1961
|
+
type: "star",
|
|
1962
|
+
value,
|
|
1963
|
+
output: star
|
|
1964
|
+
};
|
|
1965
|
+
if (opts.bash === true) {
|
|
1966
|
+
token.output = ".*?";
|
|
1967
|
+
if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
|
|
1968
|
+
push(token);
|
|
1969
|
+
continue;
|
|
1970
|
+
}
|
|
1971
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1972
|
+
token.output = value;
|
|
1973
|
+
push(token);
|
|
1974
|
+
continue;
|
|
1975
|
+
}
|
|
1976
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1977
|
+
if (prev.type === "dot") {
|
|
1978
|
+
state.output += NO_DOT_SLASH;
|
|
1979
|
+
prev.output += NO_DOT_SLASH;
|
|
1980
|
+
} else if (opts.dot === true) {
|
|
1981
|
+
state.output += NO_DOTS_SLASH;
|
|
1982
|
+
prev.output += NO_DOTS_SLASH;
|
|
1983
|
+
} else {
|
|
1984
|
+
state.output += nodot;
|
|
1985
|
+
prev.output += nodot;
|
|
1986
|
+
}
|
|
1987
|
+
if (peek() !== "*") {
|
|
1988
|
+
state.output += ONE_CHAR;
|
|
1989
|
+
prev.output += ONE_CHAR;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
push(token);
|
|
1993
|
+
}
|
|
1994
|
+
while (state.brackets > 0) {
|
|
1995
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1996
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1997
|
+
decrement("brackets");
|
|
1998
|
+
}
|
|
1999
|
+
while (state.parens > 0) {
|
|
2000
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
2001
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
2002
|
+
decrement("parens");
|
|
2003
|
+
}
|
|
2004
|
+
while (state.braces > 0) {
|
|
2005
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
2006
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
2007
|
+
decrement("braces");
|
|
2008
|
+
}
|
|
2009
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
|
|
2010
|
+
type: "maybe_slash",
|
|
2011
|
+
value: "",
|
|
2012
|
+
output: `${SLASH_LITERAL}?`
|
|
2013
|
+
});
|
|
2014
|
+
if (state.backtrack === true) {
|
|
2015
|
+
state.output = "";
|
|
2016
|
+
for (const token of state.tokens) {
|
|
2017
|
+
state.output += token.output != null ? token.output : token.value;
|
|
2018
|
+
if (token.suffix) state.output += token.suffix;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return state;
|
|
2022
|
+
};
|
|
2023
|
+
/**
|
|
2024
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
2025
|
+
* This can significantly speed up processing and has very little downside
|
|
2026
|
+
* impact when none of the fast paths match.
|
|
2027
|
+
*/
|
|
2028
|
+
parse.fastpaths = (input, options) => {
|
|
2029
|
+
const opts = { ...options };
|
|
2030
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
2031
|
+
const len = input.length;
|
|
2032
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
2033
|
+
input = REPLACEMENTS[input] || input;
|
|
2034
|
+
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
2035
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
2036
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
2037
|
+
const capture = opts.capture ? "" : "?:";
|
|
2038
|
+
const state = {
|
|
2039
|
+
negated: false,
|
|
2040
|
+
prefix: ""
|
|
2041
|
+
};
|
|
2042
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
2043
|
+
if (opts.capture) star = `(${star})`;
|
|
2044
|
+
const globstar = (opts) => {
|
|
2045
|
+
if (opts.noglobstar === true) return star;
|
|
2046
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
2047
|
+
};
|
|
2048
|
+
const create = (str) => {
|
|
2049
|
+
switch (str) {
|
|
2050
|
+
case "*": return `${nodot}${ONE_CHAR}${star}`;
|
|
2051
|
+
case ".*": return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2052
|
+
case "*.*": return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2053
|
+
case "*/*": return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
2054
|
+
case "**": return nodot + globstar(opts);
|
|
2055
|
+
case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
2056
|
+
case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2057
|
+
case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2058
|
+
default: {
|
|
2059
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
2060
|
+
if (!match) return;
|
|
2061
|
+
const source = create(match[1]);
|
|
2062
|
+
if (!source) return;
|
|
2063
|
+
return source + DOT_LITERAL + match[2];
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
let source = create(utils.removePrefix(input, state));
|
|
2068
|
+
if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL}?`;
|
|
2069
|
+
return source;
|
|
2070
|
+
};
|
|
2071
|
+
module.exports = parse;
|
|
2072
|
+
}));
|
|
2073
|
+
//#endregion
|
|
2074
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js
|
|
2075
|
+
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2076
|
+
const scan = require_scan();
|
|
2077
|
+
const parse = require_parse();
|
|
2078
|
+
const utils = require_utils();
|
|
2079
|
+
const constants = require_constants();
|
|
2080
|
+
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
2081
|
+
/**
|
|
2082
|
+
* Creates a matcher function from one or more glob patterns. The
|
|
2083
|
+
* returned function takes a string to match as its first argument,
|
|
2084
|
+
* and returns true if the string is a match. The returned matcher
|
|
2085
|
+
* function also takes a boolean as the second argument that, when true,
|
|
2086
|
+
* returns an object with additional information.
|
|
2087
|
+
*
|
|
2088
|
+
* ```js
|
|
2089
|
+
* const picomatch = require('picomatch');
|
|
2090
|
+
* // picomatch(glob[, options]);
|
|
2091
|
+
*
|
|
2092
|
+
* const isMatch = picomatch('*.!(*a)');
|
|
2093
|
+
* console.log(isMatch('a.a')); //=> false
|
|
2094
|
+
* console.log(isMatch('a.b')); //=> true
|
|
2095
|
+
* ```
|
|
2096
|
+
* @name picomatch
|
|
2097
|
+
* @param {String|Array} `globs` One or more glob patterns.
|
|
2098
|
+
* @param {Object=} `options`
|
|
2099
|
+
* @return {Function=} Returns a matcher function.
|
|
2100
|
+
* @api public
|
|
2101
|
+
*/
|
|
2102
|
+
const picomatch = (glob, options, returnState = false) => {
|
|
2103
|
+
if (Array.isArray(glob)) {
|
|
2104
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
2105
|
+
const arrayMatcher = (str) => {
|
|
2106
|
+
for (const isMatch of fns) {
|
|
2107
|
+
const state = isMatch(str);
|
|
2108
|
+
if (state) return state;
|
|
2109
|
+
}
|
|
2110
|
+
return false;
|
|
2111
|
+
};
|
|
2112
|
+
return arrayMatcher;
|
|
2113
|
+
}
|
|
2114
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
2115
|
+
if (glob === "" || typeof glob !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
|
|
2116
|
+
const opts = options || {};
|
|
2117
|
+
const posix = opts.windows;
|
|
2118
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
2119
|
+
const state = regex.state;
|
|
2120
|
+
delete regex.state;
|
|
2121
|
+
let isIgnored = () => false;
|
|
2122
|
+
if (opts.ignore) {
|
|
2123
|
+
const ignoreOpts = {
|
|
2124
|
+
...options,
|
|
2125
|
+
ignore: null,
|
|
2126
|
+
onMatch: null,
|
|
2127
|
+
onResult: null
|
|
2128
|
+
};
|
|
2129
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
2130
|
+
}
|
|
2131
|
+
const matcher = (input, returnObject = false) => {
|
|
2132
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
2133
|
+
glob,
|
|
2134
|
+
posix
|
|
2135
|
+
});
|
|
2136
|
+
const result = {
|
|
2137
|
+
glob,
|
|
2138
|
+
state,
|
|
2139
|
+
regex,
|
|
2140
|
+
posix,
|
|
2141
|
+
input,
|
|
2142
|
+
output,
|
|
2143
|
+
match,
|
|
2144
|
+
isMatch
|
|
2145
|
+
};
|
|
2146
|
+
if (typeof opts.onResult === "function") opts.onResult(result);
|
|
2147
|
+
if (isMatch === false) {
|
|
2148
|
+
result.isMatch = false;
|
|
2149
|
+
return returnObject ? result : false;
|
|
2150
|
+
}
|
|
2151
|
+
if (isIgnored(input)) {
|
|
2152
|
+
if (typeof opts.onIgnore === "function") opts.onIgnore(result);
|
|
2153
|
+
result.isMatch = false;
|
|
2154
|
+
return returnObject ? result : false;
|
|
2155
|
+
}
|
|
2156
|
+
if (typeof opts.onMatch === "function") opts.onMatch(result);
|
|
2157
|
+
return returnObject ? result : true;
|
|
2158
|
+
};
|
|
2159
|
+
if (returnState) matcher.state = state;
|
|
2160
|
+
return matcher;
|
|
2161
|
+
};
|
|
2162
|
+
/**
|
|
2163
|
+
* Test `input` with the given `regex`. This is used by the main
|
|
2164
|
+
* `picomatch()` function to test the input string.
|
|
2165
|
+
*
|
|
2166
|
+
* ```js
|
|
2167
|
+
* const picomatch = require('picomatch');
|
|
2168
|
+
* // picomatch.test(input, regex[, options]);
|
|
2169
|
+
*
|
|
2170
|
+
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
2171
|
+
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
2172
|
+
* ```
|
|
2173
|
+
* @param {String} `input` String to test.
|
|
2174
|
+
* @param {RegExp} `regex`
|
|
2175
|
+
* @return {Object} Returns an object with matching info.
|
|
2176
|
+
* @api public
|
|
2177
|
+
*/
|
|
2178
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
2179
|
+
if (typeof input !== "string") throw new TypeError("Expected input to be a string");
|
|
2180
|
+
if (input === "") return {
|
|
2181
|
+
isMatch: false,
|
|
2182
|
+
output: ""
|
|
2183
|
+
};
|
|
2184
|
+
const opts = options || {};
|
|
2185
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
2186
|
+
let match = input === glob;
|
|
2187
|
+
let output = match && format ? format(input) : input;
|
|
2188
|
+
if (match === false) {
|
|
2189
|
+
output = format ? format(input) : input;
|
|
2190
|
+
match = output === glob;
|
|
2191
|
+
}
|
|
2192
|
+
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
|
|
2193
|
+
else match = regex.exec(output);
|
|
2194
|
+
return {
|
|
2195
|
+
isMatch: Boolean(match),
|
|
2196
|
+
match,
|
|
2197
|
+
output
|
|
2198
|
+
};
|
|
2199
|
+
};
|
|
2200
|
+
/**
|
|
2201
|
+
* Match the basename of a filepath.
|
|
2202
|
+
*
|
|
2203
|
+
* ```js
|
|
2204
|
+
* const picomatch = require('picomatch');
|
|
2205
|
+
* // picomatch.matchBase(input, glob[, options]);
|
|
2206
|
+
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
2207
|
+
* ```
|
|
2208
|
+
* @param {String} `input` String to test.
|
|
2209
|
+
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
2210
|
+
* @return {Boolean}
|
|
2211
|
+
* @api public
|
|
2212
|
+
*/
|
|
2213
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
2214
|
+
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(utils.basename(input));
|
|
2215
|
+
};
|
|
2216
|
+
/**
|
|
2217
|
+
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
2218
|
+
*
|
|
2219
|
+
* ```js
|
|
2220
|
+
* const picomatch = require('picomatch');
|
|
2221
|
+
* // picomatch.isMatch(string, patterns[, options]);
|
|
2222
|
+
*
|
|
2223
|
+
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
2224
|
+
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
2225
|
+
* ```
|
|
2226
|
+
* @param {String|Array} str The string to test.
|
|
2227
|
+
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
2228
|
+
* @param {Object} [options] See available [options](#options).
|
|
2229
|
+
* @return {Boolean} Returns true if any patterns match `str`
|
|
2230
|
+
* @api public
|
|
2231
|
+
*/
|
|
2232
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
2233
|
+
/**
|
|
2234
|
+
* Parse a glob pattern to create the source string for a regular
|
|
2235
|
+
* expression.
|
|
2236
|
+
*
|
|
2237
|
+
* ```js
|
|
2238
|
+
* const picomatch = require('picomatch');
|
|
2239
|
+
* const result = picomatch.parse(pattern[, options]);
|
|
2240
|
+
* ```
|
|
2241
|
+
* @param {String} `pattern`
|
|
2242
|
+
* @param {Object} `options`
|
|
2243
|
+
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
2244
|
+
* @api public
|
|
2245
|
+
*/
|
|
2246
|
+
picomatch.parse = (pattern, options) => {
|
|
2247
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
2248
|
+
return parse(pattern, {
|
|
2249
|
+
...options,
|
|
2250
|
+
fastpaths: false
|
|
2251
|
+
});
|
|
2252
|
+
};
|
|
2253
|
+
/**
|
|
2254
|
+
* Scan a glob pattern to separate the pattern into segments.
|
|
2255
|
+
*
|
|
2256
|
+
* ```js
|
|
2257
|
+
* const picomatch = require('picomatch');
|
|
2258
|
+
* // picomatch.scan(input[, options]);
|
|
2259
|
+
*
|
|
2260
|
+
* const result = picomatch.scan('!./foo/*.js');
|
|
2261
|
+
* console.log(result);
|
|
2262
|
+
* { prefix: '!./',
|
|
2263
|
+
* input: '!./foo/*.js',
|
|
2264
|
+
* start: 3,
|
|
2265
|
+
* base: 'foo',
|
|
2266
|
+
* glob: '*.js',
|
|
2267
|
+
* isBrace: false,
|
|
2268
|
+
* isBracket: false,
|
|
2269
|
+
* isGlob: true,
|
|
2270
|
+
* isExtglob: false,
|
|
2271
|
+
* isGlobstar: false,
|
|
2272
|
+
* negated: true }
|
|
2273
|
+
* ```
|
|
2274
|
+
* @param {String} `input` Glob pattern to scan.
|
|
2275
|
+
* @param {Object} `options`
|
|
2276
|
+
* @return {Object} Returns an object with
|
|
2277
|
+
* @api public
|
|
2278
|
+
*/
|
|
2279
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
2280
|
+
/**
|
|
2281
|
+
* Compile a regular expression from the `state` object returned by the
|
|
2282
|
+
* [parse()](#parse) method.
|
|
2283
|
+
*
|
|
2284
|
+
* ```js
|
|
2285
|
+
* const picomatch = require('picomatch');
|
|
2286
|
+
* const state = picomatch.parse('*.js');
|
|
2287
|
+
* // picomatch.compileRe(state[, options]);
|
|
2288
|
+
*
|
|
2289
|
+
* console.log(picomatch.compileRe(state));
|
|
2290
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2291
|
+
* ```
|
|
2292
|
+
* @param {Object} `state`
|
|
2293
|
+
* @param {Object} `options`
|
|
2294
|
+
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
2295
|
+
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
2296
|
+
* @return {RegExp}
|
|
2297
|
+
* @api public
|
|
2298
|
+
*/
|
|
2299
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
2300
|
+
if (returnOutput === true) return state.output;
|
|
2301
|
+
const opts = options || {};
|
|
2302
|
+
const prepend = opts.contains ? "" : "^";
|
|
2303
|
+
const append = opts.contains ? "" : "$";
|
|
2304
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
2305
|
+
if (state && state.negated === true) source = `^(?!${source}).*$`;
|
|
2306
|
+
const regex = picomatch.toRegex(source, options);
|
|
2307
|
+
if (returnState === true) regex.state = state;
|
|
2308
|
+
return regex;
|
|
2309
|
+
};
|
|
2310
|
+
/**
|
|
2311
|
+
* Create a regular expression from a parsed glob pattern.
|
|
2312
|
+
*
|
|
2313
|
+
* ```js
|
|
2314
|
+
* const picomatch = require('picomatch');
|
|
2315
|
+
* // picomatch.makeRe(state[, options]);
|
|
2316
|
+
*
|
|
2317
|
+
* const result = picomatch.makeRe('*.js');
|
|
2318
|
+
* console.log(result);
|
|
2319
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2320
|
+
* ```
|
|
2321
|
+
* @param {String} `state` The object returned from the `.parse` method.
|
|
2322
|
+
* @param {Object} `options`
|
|
2323
|
+
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
2324
|
+
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
2325
|
+
* @return {RegExp} Returns a regex created from the given pattern.
|
|
2326
|
+
* @api public
|
|
2327
|
+
*/
|
|
2328
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
2329
|
+
if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
|
|
2330
|
+
let parsed = {
|
|
2331
|
+
negated: false,
|
|
2332
|
+
fastpaths: true
|
|
2333
|
+
};
|
|
2334
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
|
|
2335
|
+
if (!parsed.output) parsed = parse(input, options);
|
|
2336
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
2337
|
+
};
|
|
2338
|
+
/**
|
|
2339
|
+
* Create a regular expression from the given regex source string.
|
|
2340
|
+
*
|
|
2341
|
+
* ```js
|
|
2342
|
+
* const picomatch = require('picomatch');
|
|
2343
|
+
* // picomatch.toRegex(source[, options]);
|
|
2344
|
+
*
|
|
2345
|
+
* const { output } = picomatch.parse('*.js');
|
|
2346
|
+
* console.log(picomatch.toRegex(output));
|
|
2347
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2348
|
+
* ```
|
|
2349
|
+
* @param {String} `source` Regular expression source string.
|
|
2350
|
+
* @param {Object} `options`
|
|
2351
|
+
* @return {RegExp}
|
|
2352
|
+
* @api public
|
|
2353
|
+
*/
|
|
2354
|
+
picomatch.toRegex = (source, options) => {
|
|
2355
|
+
try {
|
|
2356
|
+
const opts = options || {};
|
|
2357
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
2358
|
+
} catch (err) {
|
|
2359
|
+
if (options && options.debug === true) throw err;
|
|
2360
|
+
return /$^/;
|
|
2361
|
+
}
|
|
2362
|
+
};
|
|
2363
|
+
/**
|
|
2364
|
+
* Picomatch constants.
|
|
2365
|
+
* @return {Object}
|
|
2366
|
+
*/
|
|
2367
|
+
picomatch.constants = constants;
|
|
2368
|
+
/**
|
|
2369
|
+
* Expose "picomatch"
|
|
2370
|
+
*/
|
|
2371
|
+
module.exports = picomatch;
|
|
2372
|
+
}));
|
|
2373
|
+
//#endregion
|
|
2374
|
+
//#region ../../node_modules/.pnpm/tinyglobby@0.2.16/node_modules/tinyglobby/dist/index.mjs
|
|
2375
|
+
var import_picomatch = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2376
|
+
const pico = require_picomatch$1();
|
|
2377
|
+
const utils = require_utils();
|
|
2378
|
+
function picomatch(glob, options, returnState = false) {
|
|
2379
|
+
if (options && (options.windows === null || options.windows === void 0)) options = {
|
|
2380
|
+
...options,
|
|
2381
|
+
windows: utils.isWindows()
|
|
2382
|
+
};
|
|
2383
|
+
return pico(glob, options, returnState);
|
|
2384
|
+
}
|
|
2385
|
+
Object.assign(picomatch, pico);
|
|
2386
|
+
module.exports = picomatch;
|
|
2387
|
+
})))(), 1);
|
|
2388
|
+
const isReadonlyArray = Array.isArray;
|
|
2389
|
+
const BACKSLASHES = /\\/g;
|
|
2390
|
+
const isWin = process.platform === "win32";
|
|
2391
|
+
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
2392
|
+
function getPartialMatcher(patterns, options = {}) {
|
|
2393
|
+
const patternsCount = patterns.length;
|
|
2394
|
+
const patternsParts = Array(patternsCount);
|
|
2395
|
+
const matchers = Array(patternsCount);
|
|
2396
|
+
let i, j;
|
|
2397
|
+
for (i = 0; i < patternsCount; i++) {
|
|
2398
|
+
const parts = splitPattern(patterns[i]);
|
|
2399
|
+
patternsParts[i] = parts;
|
|
2400
|
+
const partsCount = parts.length;
|
|
2401
|
+
const partMatchers = Array(partsCount);
|
|
2402
|
+
for (j = 0; j < partsCount; j++) partMatchers[j] = (0, import_picomatch.default)(parts[j], options);
|
|
2403
|
+
matchers[i] = partMatchers;
|
|
2404
|
+
}
|
|
2405
|
+
return (input) => {
|
|
2406
|
+
const inputParts = input.split("/");
|
|
2407
|
+
if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
|
2408
|
+
for (i = 0; i < patternsCount; i++) {
|
|
2409
|
+
const patternParts = patternsParts[i];
|
|
2410
|
+
const matcher = matchers[i];
|
|
2411
|
+
const inputPatternCount = inputParts.length;
|
|
2412
|
+
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
2413
|
+
j = 0;
|
|
2414
|
+
while (j < minParts) {
|
|
2415
|
+
const part = patternParts[j];
|
|
2416
|
+
if (part.includes("/")) return true;
|
|
2417
|
+
if (!matcher[j](inputParts[j])) break;
|
|
2418
|
+
if (!options.noglobstar && part === "**") return true;
|
|
2419
|
+
j++;
|
|
2420
|
+
}
|
|
2421
|
+
if (j === inputPatternCount) return true;
|
|
2422
|
+
}
|
|
2423
|
+
return false;
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
/* node:coverage ignore next 2 */
|
|
2427
|
+
const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
|
|
2428
|
+
const isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
|
|
2429
|
+
function buildFormat(cwd, root, absolute) {
|
|
2430
|
+
if (cwd === root || root.startsWith(`${cwd}/`)) {
|
|
2431
|
+
if (absolute) {
|
|
2432
|
+
const start = cwd.length + +!isRoot(cwd);
|
|
2433
|
+
return (p, isDir) => p.slice(start, isDir ? -1 : void 0) || ".";
|
|
2434
|
+
}
|
|
2435
|
+
const prefix = root.slice(cwd.length + 1);
|
|
2436
|
+
if (prefix) return (p, isDir) => {
|
|
2437
|
+
if (p === ".") return prefix;
|
|
2438
|
+
const result = `${prefix}/${p}`;
|
|
2439
|
+
return isDir ? result.slice(0, -1) : result;
|
|
2440
|
+
};
|
|
2441
|
+
return (p, isDir) => isDir && p !== "." ? p.slice(0, -1) : p;
|
|
2442
|
+
}
|
|
2443
|
+
if (absolute) return (p) => posix.relative(cwd, p) || ".";
|
|
2444
|
+
return (p) => posix.relative(cwd, `${root}/${p}`) || ".";
|
|
2445
|
+
}
|
|
2446
|
+
function buildRelative(cwd, root) {
|
|
2447
|
+
if (root.startsWith(`${cwd}/`)) {
|
|
2448
|
+
const prefix = root.slice(cwd.length + 1);
|
|
2449
|
+
return (p) => `${prefix}/${p}`;
|
|
2450
|
+
}
|
|
2451
|
+
return (p) => {
|
|
2452
|
+
const result = posix.relative(cwd, `${root}/${p}`);
|
|
2453
|
+
return p[p.length - 1] === "/" && result !== "" ? `${result}/` : result || ".";
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
const splitPatternOptions = { parts: true };
|
|
2457
|
+
function splitPattern(path) {
|
|
2458
|
+
var _result$parts;
|
|
2459
|
+
const result = import_picomatch.default.scan(path, splitPatternOptions);
|
|
2460
|
+
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path];
|
|
2461
|
+
}
|
|
2462
|
+
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
2463
|
+
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
2464
|
+
const escapePosixPath = (path) => path.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2465
|
+
const escapeWin32Path = (path) => path.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2466
|
+
/**
|
|
2467
|
+
* Escapes a path's special characters depending on the platform.
|
|
2468
|
+
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
|
2469
|
+
*/
|
|
2470
|
+
/* node:coverage ignore next */
|
|
2471
|
+
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
2472
|
+
/**
|
|
2473
|
+
* Checks if a pattern has dynamic parts.
|
|
2474
|
+
*
|
|
2475
|
+
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
|
|
2476
|
+
*
|
|
2477
|
+
* - Doesn't necessarily return `false` on patterns that include `\`.
|
|
2478
|
+
* - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
|
|
2479
|
+
* - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
|
|
2480
|
+
* - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
|
|
2481
|
+
*
|
|
2482
|
+
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
|
|
2483
|
+
*/
|
|
2484
|
+
function isDynamicPattern(pattern, options) {
|
|
2485
|
+
if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
|
|
2486
|
+
const scan = import_picomatch.default.scan(pattern);
|
|
2487
|
+
return scan.isGlob || scan.negated;
|
|
2488
|
+
}
|
|
2489
|
+
function log(...tasks) {
|
|
2490
|
+
console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
|
|
2491
|
+
}
|
|
2492
|
+
function ensureStringArray(value) {
|
|
2493
|
+
return typeof value === "string" ? [value] : value !== null && value !== void 0 ? value : [];
|
|
2494
|
+
}
|
|
2495
|
+
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
2496
|
+
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
2497
|
+
function normalizePattern(pattern, opts, props, isIgnore) {
|
|
2498
|
+
var _PARENT_DIRECTORY$exe;
|
|
2499
|
+
const cwd = opts.cwd;
|
|
2500
|
+
let result = pattern;
|
|
2501
|
+
if (pattern[pattern.length - 1] === "/") result = pattern.slice(0, -1);
|
|
2502
|
+
if (result[result.length - 1] !== "*" && opts.expandDirectories) result += "/**";
|
|
2503
|
+
const escapedCwd = escapePath(cwd);
|
|
2504
|
+
result = isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
|
|
2505
|
+
const parentDir = (_PARENT_DIRECTORY$exe = PARENT_DIRECTORY.exec(result)) === null || _PARENT_DIRECTORY$exe === void 0 ? void 0 : _PARENT_DIRECTORY$exe[0];
|
|
2506
|
+
const parts = splitPattern(result);
|
|
2507
|
+
if (parentDir) {
|
|
2508
|
+
const n = (parentDir.length + 1) / 3;
|
|
2509
|
+
let i = 0;
|
|
2510
|
+
const cwdParts = escapedCwd.split("/");
|
|
2511
|
+
while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
|
|
2512
|
+
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
2513
|
+
i++;
|
|
2514
|
+
}
|
|
2515
|
+
const potentialRoot = posix.join(cwd, parentDir.slice(i * 3));
|
|
2516
|
+
if (potentialRoot[0] !== "." && props.root.length > potentialRoot.length) {
|
|
2517
|
+
props.root = potentialRoot;
|
|
2518
|
+
props.depthOffset = -n + i;
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
if (!isIgnore && props.depthOffset >= 0) {
|
|
2522
|
+
var _props$commonPath;
|
|
2523
|
+
(_props$commonPath = props.commonPath) !== null && _props$commonPath !== void 0 || (props.commonPath = parts);
|
|
2524
|
+
const newCommonPath = [];
|
|
2525
|
+
const length = Math.min(props.commonPath.length, parts.length);
|
|
2526
|
+
for (let i = 0; i < length; i++) {
|
|
2527
|
+
const part = parts[i];
|
|
2528
|
+
if (part === "**" && !parts[i + 1]) {
|
|
2529
|
+
newCommonPath.pop();
|
|
2530
|
+
break;
|
|
2531
|
+
}
|
|
2532
|
+
if (i === parts.length - 1 || part !== props.commonPath[i] || isDynamicPattern(part)) break;
|
|
2533
|
+
newCommonPath.push(part);
|
|
2534
|
+
}
|
|
2535
|
+
props.depthOffset = newCommonPath.length;
|
|
2536
|
+
props.commonPath = newCommonPath;
|
|
2537
|
+
props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
|
|
2538
|
+
}
|
|
2539
|
+
return result;
|
|
2540
|
+
}
|
|
2541
|
+
function processPatterns(options, patterns, props) {
|
|
2542
|
+
const matchPatterns = [];
|
|
2543
|
+
const ignorePatterns = [];
|
|
2544
|
+
for (const pattern of options.ignore) {
|
|
2545
|
+
if (!pattern) continue;
|
|
2546
|
+
if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, options, props, true));
|
|
2547
|
+
}
|
|
2548
|
+
for (const pattern of patterns) {
|
|
2549
|
+
if (!pattern) continue;
|
|
2550
|
+
if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, options, props, false));
|
|
2551
|
+
else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), options, props, true));
|
|
2552
|
+
}
|
|
2553
|
+
return {
|
|
2554
|
+
match: matchPatterns,
|
|
2555
|
+
ignore: ignorePatterns
|
|
2556
|
+
};
|
|
2557
|
+
}
|
|
2558
|
+
function buildCrawler(options, patterns) {
|
|
2559
|
+
const cwd = options.cwd;
|
|
2560
|
+
const props = {
|
|
2561
|
+
root: cwd,
|
|
2562
|
+
depthOffset: 0
|
|
2563
|
+
};
|
|
2564
|
+
const processed = processPatterns(options, patterns, props);
|
|
2565
|
+
if (options.debug) log("internal processing patterns:", processed);
|
|
2566
|
+
const { absolute, caseSensitiveMatch, debug, dot, followSymbolicLinks, onlyDirectories } = options;
|
|
2567
|
+
const root = props.root.replace(BACKSLASHES, "");
|
|
2568
|
+
const matchOptions = {
|
|
2569
|
+
dot,
|
|
2570
|
+
nobrace: options.braceExpansion === false,
|
|
2571
|
+
nocase: !caseSensitiveMatch,
|
|
2572
|
+
noextglob: options.extglob === false,
|
|
2573
|
+
noglobstar: options.globstar === false,
|
|
2574
|
+
posix: true
|
|
2575
|
+
};
|
|
2576
|
+
const matcher = (0, import_picomatch.default)(processed.match, matchOptions);
|
|
2577
|
+
const ignore = (0, import_picomatch.default)(processed.ignore, matchOptions);
|
|
2578
|
+
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
|
2579
|
+
const format = buildFormat(cwd, root, absolute);
|
|
2580
|
+
const excludeFormatter = absolute ? format : buildFormat(cwd, root, true);
|
|
2581
|
+
const excludePredicate = (_, p) => {
|
|
2582
|
+
const relativePath = excludeFormatter(p, true);
|
|
2583
|
+
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2584
|
+
};
|
|
2585
|
+
let maxDepth;
|
|
2586
|
+
if (options.deep !== void 0) maxDepth = Math.round(options.deep - props.depthOffset);
|
|
2587
|
+
const crawler = new Builder({
|
|
2588
|
+
filters: [debug ? (p, isDirectory) => {
|
|
2589
|
+
const path = format(p, isDirectory);
|
|
2590
|
+
const matches = matcher(path) && !ignore(path);
|
|
2591
|
+
if (matches) log(`matched ${path}`);
|
|
2592
|
+
return matches;
|
|
2593
|
+
} : (p, isDirectory) => {
|
|
2594
|
+
const path = format(p, isDirectory);
|
|
2595
|
+
return matcher(path) && !ignore(path);
|
|
2596
|
+
}],
|
|
2597
|
+
exclude: debug ? (_, p) => {
|
|
2598
|
+
const skipped = excludePredicate(_, p);
|
|
2599
|
+
log(`${skipped ? "skipped" : "crawling"} ${p}`);
|
|
2600
|
+
return skipped;
|
|
2601
|
+
} : excludePredicate,
|
|
2602
|
+
fs: options.fs,
|
|
2603
|
+
pathSeparator: "/",
|
|
2604
|
+
relativePaths: !absolute,
|
|
2605
|
+
resolvePaths: absolute,
|
|
2606
|
+
includeBasePath: absolute,
|
|
2607
|
+
resolveSymlinks: followSymbolicLinks,
|
|
2608
|
+
excludeSymlinks: !followSymbolicLinks,
|
|
2609
|
+
excludeFiles: onlyDirectories,
|
|
2610
|
+
includeDirs: onlyDirectories || !options.onlyFiles,
|
|
2611
|
+
maxDepth,
|
|
2612
|
+
signal: options.signal
|
|
2613
|
+
}).crawl(root);
|
|
2614
|
+
if (options.debug) log("internal properties:", {
|
|
2615
|
+
...props,
|
|
2616
|
+
root
|
|
2617
|
+
});
|
|
2618
|
+
return [crawler, cwd !== root && !absolute && buildRelative(cwd, root)];
|
|
2619
|
+
}
|
|
2620
|
+
function formatPaths(paths, mapper) {
|
|
2621
|
+
if (mapper) for (let i = paths.length - 1; i >= 0; i--) paths[i] = mapper(paths[i]);
|
|
2622
|
+
return paths;
|
|
2623
|
+
}
|
|
2624
|
+
const defaultOptions = {
|
|
2625
|
+
caseSensitiveMatch: true,
|
|
2626
|
+
cwd: process.cwd(),
|
|
2627
|
+
debug: !!process.env.TINYGLOBBY_DEBUG,
|
|
2628
|
+
expandDirectories: true,
|
|
2629
|
+
followSymbolicLinks: true,
|
|
2630
|
+
onlyFiles: true
|
|
2631
|
+
};
|
|
2632
|
+
function getOptions(options) {
|
|
2633
|
+
const opts = {
|
|
2634
|
+
...defaultOptions,
|
|
2635
|
+
...options
|
|
2636
|
+
};
|
|
2637
|
+
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd)).replace(BACKSLASHES, "/");
|
|
2638
|
+
opts.ignore = ensureStringArray(opts.ignore);
|
|
2639
|
+
opts.fs && (opts.fs = {
|
|
2640
|
+
readdir: opts.fs.readdir || readdir,
|
|
2641
|
+
readdirSync: opts.fs.readdirSync || readdirSync,
|
|
2642
|
+
realpath: opts.fs.realpath || realpath,
|
|
2643
|
+
realpathSync: opts.fs.realpathSync || realpathSync,
|
|
2644
|
+
stat: opts.fs.stat || stat,
|
|
2645
|
+
statSync: opts.fs.statSync || statSync
|
|
2646
|
+
});
|
|
2647
|
+
if (opts.debug) log("globbing with options:", opts);
|
|
2648
|
+
return opts;
|
|
2649
|
+
}
|
|
2650
|
+
function getCrawler(globInput, inputOptions = {}) {
|
|
2651
|
+
var _ref;
|
|
2652
|
+
if (globInput && (inputOptions === null || inputOptions === void 0 ? void 0 : inputOptions.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2653
|
+
const isModern = isReadonlyArray(globInput) || typeof globInput === "string";
|
|
2654
|
+
const patterns = ensureStringArray((_ref = isModern ? globInput : globInput.patterns) !== null && _ref !== void 0 ? _ref : "**/*");
|
|
2655
|
+
const options = getOptions(isModern ? inputOptions : globInput);
|
|
2656
|
+
return patterns.length > 0 ? buildCrawler(options, patterns) : [];
|
|
2657
|
+
}
|
|
2658
|
+
async function glob(globInput, options) {
|
|
2659
|
+
const [crawler, relative] = getCrawler(globInput, options);
|
|
2660
|
+
return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
|
|
2661
|
+
}
|
|
2662
|
+
function globSync(globInput, options) {
|
|
2663
|
+
const [crawler, relative] = getCrawler(globInput, options);
|
|
2664
|
+
return crawler ? formatPaths(crawler.sync(), relative) : [];
|
|
2665
|
+
}
|
|
2666
|
+
//#endregion
|
|
2667
|
+
export { globSync as n, glob as t };
|