Skip to content

Commit

Permalink
feat: don't create resource folder in snapshot if no resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Sep 4, 2024
1 parent e8f608c commit b109d52
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/core/src/snapshot/createSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ export async function createSnapshot(mq: MoquerieInstance, options: CreateSnapsh
// Copy resources
const snapshotFolder = await getSnapshotFolder(mq, snapshotItem)
for (const resourceName in resourceIds) {
const sourceFolder = path.join(getCurrentBranchFolder(mq), resourceName)
const targetFolder = path.join(snapshotFolder, resourceName)
await ensureDir(targetFolder)
if (resourceIds[resourceName].length) {
const sourceFolder = path.join(getCurrentBranchFolder(mq), resourceName)
const targetFolder = path.join(snapshotFolder, resourceName)
await ensureDir(targetFolder)

const resourceStorage = await getResourceInstanceStorage(mq, resourceName)
const resourceStorage = await getResourceInstanceStorage(mq, resourceName)

const ids = resourceIds[resourceName]
for (const id of ids) {
const file = resourceStorage.manifest.files[id]
const sourceFile = path.join(sourceFolder, file)
const targetFile = path.join(targetFolder, `${id}.json`)
await fs.promises.copyFile(sourceFile, targetFile)
const ids = resourceIds[resourceName]
for (const id of ids) {
const file = resourceStorage.manifest.files[id]
const sourceFile = path.join(sourceFolder, file)
const targetFile = path.join(targetFolder, `${id}.json`)
await fs.promises.copyFile(sourceFile, targetFile)
}
}
}

Expand Down

0 comments on commit b109d52

Please sign in to comment.