Skip to content

Commit 239de5b

Browse files
danielcondemarinsclaughl
authored andcommitted
refactor
1 parent e961db0 commit 239de5b

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
import path from "path";
22
import fse from "fs-extra";
33
import mime from "mime-types";
4-
import klaw, { Item } from "klaw";
54
import AWS from "aws-sdk";
5+
import readDirectoryFiles from "./lib/readDirectoryFiles";
66

77
type UploadStaticAssetsOptions = {
88
bucketName: string;
99
nextConfigDir: string;
1010
};
11+
1112
const filePathToS3Key = (filePath: string): string => {
1213
const relevantFilePathPart = filePath.substring(
1314
filePath.indexOf(".next" + path.sep)
1415
);
1516
return relevantFilePathPart.replace(".next", "_next");
1617
};
17-
const readDirectoryFiles = (directory: string): Promise<Array<Item>> => {
18-
const items: Item[] = [];
19-
return new Promise((resolve, reject) => {
20-
klaw(directory.trim())
21-
.on("data", item => items.push(item))
22-
.on("end", () => {
23-
resolve(items);
24-
})
25-
.on("error", reject);
26-
});
27-
};
2818

2919
const uploadStaticAssets = async (
3020
options: UploadStaticAssetsOptions
@@ -90,7 +80,6 @@ const uploadStaticAssets = async (
9080
await Promise.all(uploadTasks);
9181
// read public/ folder and upload files
9282
// read static/ folder and upload files
93-
// get HTML pages from pages manifest
9483
// get JSON data files from prerender manifest
9584
};
9685

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import klaw, { Item } from "klaw";
2+
3+
const readDirectoryFiles = (directory: string): Promise<Array<Item>> => {
4+
const items: Item[] = [];
5+
return new Promise((resolve, reject) => {
6+
klaw(directory.trim())
7+
.on("data", item => items.push(item))
8+
.on("end", () => {
9+
resolve(items);
10+
})
11+
.on("error", reject);
12+
});
13+
};
14+
15+
export default readDirectoryFiles;

0 commit comments

Comments
 (0)