sparse-intern-71089
07/16/2021, 2:43 PMmillions-furniture-75402
07/16/2021, 2:49 PMconst scanToS3 = (dirPath: string, options?: { trimDirPath?: boolean; ignoreTypes?: RegExp | string }): void => {
for (const item of fs.readdirSync(dirPath)) {
const itemDirPath = path.join(dirPath, item);
let itemKey = itemDirPath;
if (options && options.trimDirPath) {
const dirPathArr = dirPath.split("/");
const rootFolder = dirPathArr[0] === "." ? dirPathArr[1] : dirPathArr[0];
itemKey = itemDirPath.replace(new RegExp(`^${rootFolder}`), "");
}
if (fs.statSync(itemDirPath).isFile()) {
if (options && (!options.ignoreTypes || !item.match(options.ignoreTypes))) {
new aws.s3.BucketObject(itemDirPath, {
bucket: staticSiteBucket,
source: new pulumi.asset.FileAsset(itemDirPath),
key: itemKey,
contentType: mime.getType(itemDirPath) || undefined,
});
}
} else {
scanToS3(itemDirPath, options);
}
}
};
scanToS3("./dist/", { trimDirPath: true });
millions-furniture-75402
07/16/2021, 2:49 PMfull-artist-27215
07/16/2021, 2:51 PM