Skip to content

Commit 55aba75

Browse files
fix(build): handle specific file paths in getGlobBase for destination option
When a pattern has no glob characters (e.g., './config/settings.json'), return the parent directory instead of the full path. This ensures that relative() preserves the filename when computing the destination path. Co-authored-by: Eric Allam <[email protected]>
1 parent a6e718a commit 55aba75

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/build/src/internal/additionalFiles.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,27 @@ async function findStaticAssetFiles(
7575

7676
// Extracts the base directory from a glob pattern (the non-wildcard prefix).
7777
// For example: "../shared/**" -> "../shared", "./assets/*.txt" -> "./assets"
78+
// For specific files without globs: "./config/settings.json" -> "./config" (parent dir)
7879
function getGlobBase(pattern: string): string {
7980
const parts = pattern.split(/[/\\]/);
8081
const baseParts: string[] = [];
82+
let hasGlobCharacters = false;
8183

8284
for (const part of parts) {
8385
// Stop at the first part that contains glob characters
8486
if (part.includes("*") || part.includes("?") || part.includes("[") || part.includes("{")) {
87+
hasGlobCharacters = true;
8588
break;
8689
}
8790
baseParts.push(part);
8891
}
8992

93+
// If no glob characters were found, the pattern is a specific file path.
94+
// Return the parent directory so that relative() preserves the filename.
95+
if (!hasGlobCharacters && baseParts.length > 1) {
96+
baseParts.pop(); // Remove the filename, keep the directory
97+
}
98+
9099
return baseParts.length > 0 ? baseParts.join(posix.sep) : ".";
91100
}
92101

0 commit comments

Comments
 (0)