From 478cd9d8fa9452466a73e0981863ef6e82f87238 Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Mon, 26 Jun 2023 11:27:39 +0200 Subject: [PATCH] fix: Installs underneath a path containing leading underscores (#7476) --- .changeset/flat-papayas-invite.md | 5 +++++ .../astro/src/content/vite-plugin-content-virtual-mod.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/flat-papayas-invite.md diff --git a/.changeset/flat-papayas-invite.md b/.changeset/flat-papayas-invite.md new file mode 100644 index 000000000000..c8b1193d7662 --- /dev/null +++ b/.changeset/flat-papayas-invite.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Allow astro to be installed underneath a folder with leading slashes diff --git a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts index ecda537e2094..6ab920c4d84e 100644 --- a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts +++ b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts @@ -21,6 +21,7 @@ import { type ContentLookupMap, type ContentPaths, } from './utils.js'; +import { appendForwardSlash } from '../core/path.js'; interface AstroContentVirtualModPluginParams { settings: AstroSettings; @@ -209,5 +210,6 @@ const UnexpectedLookupMapError = new AstroError({ function globWithUnderscoresIgnored(relContentDir: string, exts: string[]): string[] { const extGlob = getExtGlob(exts); - return [`${relContentDir}/**/*${extGlob}`, `!**/_*/**${extGlob}`, `!**/_*${extGlob}`]; + const contentDir = appendForwardSlash(relContentDir); + return [`${contentDir}**/*${extGlob}`, `!${contentDir}_*/**${extGlob}`, `!${contentDir}_*${extGlob}`]; }