mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
added syncFolder
util
This commit is contained in:
parent
165c78abaa
commit
a3e9503ded
@ -0,0 +1,23 @@
|
|||||||
|
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
|
Loading…
x
Reference in New Issue
Block a user