Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit b35d6e6

Browse files
fix windows specific issues with s3 keys not being posix
1 parent 5e47477 commit b35d6e6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/s3-static-assets/src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import readDirectoryFiles from "./lib/readDirectoryFiles";
55
import filterOutDirectories from "./lib/filterOutDirectories";
66
import { IMMUTABLE_CACHE_CONTROL_HEADER } from "./lib/constants";
77
import S3ClientFactory, { Credentials } from "./lib/s3";
8+
import pathToPosix from "./lib/pathToPosix";
89

910
type UploadStaticAssetsOptions = {
1011
bucketName: string;
@@ -35,9 +36,11 @@ const uploadStaticAssets = async (
3536
const nextBuildFileUploads = buildStaticFiles
3637
.filter(filterOutDirectories)
3738
.map(async fileItem => {
38-
const s3Key = path
39-
.relative(path.resolve(nextConfigDir), fileItem.path)
40-
.replace(/^.next/, "_next");
39+
const s3Key = pathToPosix(
40+
path
41+
.relative(path.resolve(nextConfigDir), fileItem.path)
42+
.replace(/^.next/, "_next")
43+
);
4144

4245
return s3.uploadFile({
4346
s3Key,
@@ -53,9 +56,8 @@ const uploadStaticAssets = async (
5356
const htmlPageUploads = Object.values(pagesManifest)
5457
.filter(pageFile => (pageFile as string).endsWith(".html"))
5558
.map(relativePageFilePath => {
56-
const pageFilePath = path.join(
57-
dotNextDirectory,
58-
`serverless/${relativePageFilePath}`
59+
const pageFilePath = pathToPosix(
60+
path.join(dotNextDirectory, `serverless/${relativePageFilePath}`)
5961
);
6062

6163
return s3.uploadFile({
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const pathToPosix = (path: string): string => path.replace(/\\/g, "/");
2+
export default pathToPosix;

0 commit comments

Comments
 (0)