From 2d1ac0bd506d47bc3e6b603851f2922c05d8a428 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Wed, 29 Jan 2025 18:14:02 +0100 Subject: [PATCH] fix(fs): Fixed copy and copySync functions to ensure they always overwrite files. --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts/fs.ts | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 6b26aed..1a21db3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2025-01-29 - 11.1.8 - fix(fs) +Fixed copy and copySync functions to ensure they always overwrite files. + +- Fixed bug in copy function where files were not being overwritten when they already existed at the destination. +- Fixed bug in copySync function to ensure files are overwritten to match the async function's behavior. + ## 2025-01-29 - 11.1.7 - fix(fs) Refactor copy and copySync functions to simplify return type diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 74adba5..2d223d5 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartfile', - version: '11.1.7', + version: '11.1.8', description: 'Provides comprehensive tools for efficient file management in Node.js using TypeScript, including handling streams, virtual directories, and various file operations.' } diff --git a/ts/fs.ts b/ts/fs.ts index 8463269..a502c0c 100644 --- a/ts/fs.ts +++ b/ts/fs.ts @@ -75,14 +75,14 @@ export const isFile = (pathArg): boolean => { * copies a file or directory from A to B on the local disk */ export const copy = async (fromArg: string, toArg: string): Promise => { - return await plugins.fsExtra.copy(fromArg, toArg, {}); + return await plugins.fsExtra.copy(fromArg, toArg, {overwrite: true}); }; /** * copies a file or directory SYNCHRONOUSLY from A to B on the local disk */ export const copySync = (fromArg: string, toArg: string): void => { - return plugins.fsExtra.copySync(fromArg, toArg); + return plugins.fsExtra.copySync(fromArg, toArg, {overwrite: true}); }; /**