From de2053f98870ab4dcf72277d1a4860e22f58e1b1 Mon Sep 17 00:00:00 2001 From: Pragadesh-45 Date: Tue, 1 Oct 2024 14:57:19 +0530 Subject: [PATCH] refactor filesystem.js to use isWindowsOS() --- packages/bruno-electron/src/utils/filesystem.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/bruno-electron/src/utils/filesystem.js b/packages/bruno-electron/src/utils/filesystem.js index 0263939ae..8b5b63357 100644 --- a/packages/bruno-electron/src/utils/filesystem.js +++ b/packages/bruno-electron/src/utils/filesystem.js @@ -160,6 +160,10 @@ const sanitizeDirectoryName = (name) => { return name.replace(/[<>:"/\\|?*\x00-\x1F]+/g, '-'); }; +const isWindowsOS = () => { + return os.platform() === 'win32'; +} + const safeToRename = (oldPath, newPath) => { try { // If the new path doesn't exist, it's safe to rename @@ -170,7 +174,7 @@ const safeToRename = (oldPath, newPath) => { const oldStat = fs.statSync(oldPath); const newStat = fs.statSync(newPath); - if (os.platform() === 'win32') { + if (isWindowsOS()) { // Windows-specific comparison: // Check if both files have the same birth time, size (Since, Win FAT-32 doesn't use inodes) @@ -204,5 +208,6 @@ module.exports = { searchForFiles, searchForBruFiles, sanitizeDirectoryName, + isWindowsOS, safeToRename };