From 240d2d03f73d6a924b36a95f9d29b19fe4707264 Mon Sep 17 00:00:00 2001 From: Fabio GRANDE Date: Wed, 10 Jul 2024 07:54:49 +0200 Subject: [PATCH] Cloning a dir now clone also folder.bru files recursively#2593 (#2596) Co-authored-by: Fabio Grande --- packages/bruno-electron/src/ipc/collection.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index 9dfec1eb1..7928bcaa1 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -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); } @@ -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) {