Skip to content

Commit

Permalink
Cloning a dir now clone also folder.bru files recursively#2593 (usebr…
Browse files Browse the repository at this point in the history
…uno#2596)

Co-authored-by: Fabio Grande <fabio.grande@hdhome.it>
  • Loading branch information
2 people authored and jwetzell committed Aug 2, 2024
1 parent c3dbda5 commit 361d5f3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/bruno-electron/src/ipc/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,15 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
const folderPath = path.join(currentPath, item.name);
fs.mkdirSync(folderPath);

// If folder has a root element, then I should write its folder.bru file
if (item.root) {
const _folderContent = jsonToCollectionBru(item.root, true);
if (_folderContent) {
const _folderPath = path.join(folderPath, `folder.bru`);
fs.writeFileSync(_folderPath, _folderContent);
}
}

if (item.items && item.items.length) {
parseCollectionItems(item.items, folderPath);
}
Expand All @@ -543,6 +552,15 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection

await createDirectory(collectionPath);

// If initial folder has a root element, then I should write its folder.bru file
if (itemFolder.root) {
const _folderContent = jsonToCollectionBru(itemFolder.root, true);
if (_folderContent) {
const _folderPath = path.join(collectionPath, `folder.bru`);
fs.writeFileSync(_folderPath, _folderContent);
}
}

// create folder and files based on another folder
await parseCollectionItems(itemFolder.items, collectionPath);
} catch (error) {
Expand Down

0 comments on commit 361d5f3

Please sign in to comment.