From 3fbb1bc70af0e474ad96ce4ba5f7d84792cd686b Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Sun, 19 Oct 2025 13:00:26 +0200 Subject: [PATCH 1/2] Draft for sandcastle gallery pattern fix --- packages/sandcastle/scripts/buildGallery.js | 28 ++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/sandcastle/scripts/buildGallery.js b/packages/sandcastle/scripts/buildGallery.js index f03d0caa203..41faf2fc9b4 100644 --- a/packages/sandcastle/scripts/buildGallery.js +++ b/packages/sandcastle/scripts/buildGallery.js @@ -117,9 +117,31 @@ export async function buildGalleryList(options = {}) { return condition; }; - const galleryFiles = await globby( - galleryFilesPattern.map((pattern) => join(rootDirectory, pattern, "**/*")), - ); + const galleryFilesGlobbyPatterns = galleryFilesPattern.map((pattern) => { + // The join function will return the pah in a form that is normalized + // for the OS, meaning that it contains backslashes "\" on Windows + const baseGlobbyPattern = join(rootDirectory, pattern, "**/*"); + + // From the globby documentation: + // > Note that glob patterns can only contain forward-slashes, not + // > backward-slashes, so if you want to construct a glob pattern + // > from path components, you need to use path.posix.join() + // > instead of path.join(). + // However, just do the usual "replace '\' with '/'" here: + const globbyPattern = baseGlobbyPattern.replace(/\\/g, "/"); + console.log("Create globby pattern"); + console.log("rootDirectory ", rootDirectory); + console.log("pattern ", pattern); + console.log("baseGlobbyPattern ", baseGlobbyPattern); + console.log("globbyPattern ", globbyPattern); + return globbyPattern; + }); + const galleryFiles = await globby(galleryFilesGlobbyPatterns); + if (galleryFiles.length === 0) { + // TODO Warn about this and handle it somehow... + console.warn("Did not find any gallery files"); + } + const yamlFiles = galleryFiles.filter((path) => basename(path).match(galleryItemConfig), ); From 2d3442cc56765bbc8489fbc6916d9e12b8ac9ccc Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Sun, 19 Oct 2025 13:09:16 +0200 Subject: [PATCH 2/2] Important typo fix... --- packages/sandcastle/scripts/buildGallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sandcastle/scripts/buildGallery.js b/packages/sandcastle/scripts/buildGallery.js index 41faf2fc9b4..8cfe8546d92 100644 --- a/packages/sandcastle/scripts/buildGallery.js +++ b/packages/sandcastle/scripts/buildGallery.js @@ -118,7 +118,7 @@ export async function buildGalleryList(options = {}) { }; const galleryFilesGlobbyPatterns = galleryFilesPattern.map((pattern) => { - // The join function will return the pah in a form that is normalized + // The join function will return the path in a form that is normalized // for the OS, meaning that it contains backslashes "\" on Windows const baseGlobbyPattern = join(rootDirectory, pattern, "**/*");