mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
23 lines
656 B
JavaScript
Executable File
23 lines
656 B
JavaScript
Executable File
import fs from "fs"
|
|
import path from "path"
|
|
|
|
async function syncFolder(dir, destPath) {
|
|
const files = await fs.promises.readdir(dir)
|
|
|
|
for await (const file of files) {
|
|
const filePath = path.resolve(dir, file)
|
|
const desitinationFilePath = `${destPath}/${file}`
|
|
|
|
const stat = fs.statSync(filePath)
|
|
|
|
if (stat.isDirectory()) {
|
|
await syncFolder(filePath, desitinationFilePath)
|
|
} else {
|
|
const fileContent = await fs.promises.readFile(filePath)
|
|
|
|
await global.storage.putObject(process.env.S3_BUCKET, desitinationFilePath, fileContent)
|
|
}
|
|
}
|
|
}
|
|
|
|
export default syncFolder |