fix(fs): Fixed copy and copySync functions to ensure they always overwrite files.

This commit is contained in:
Philipp Kunz 2025-01-29 18:14:02 +01:00
parent 04a25221a5
commit 2d1ac0bd50
3 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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.'
}

View File

@ -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<void> => {
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});
};
/**