From ab1654bd290657b6fa93518db752cbb2aaf967ea Mon Sep 17 00:00:00 2001 From: Ivan Duplenskikh <115665590+ivanduplenskikh@users.noreply.github.com> Date: Thu, 14 Nov 2024 21:23:27 +0100 Subject: [PATCH] Add basename from source when it is a folder --- node/task.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node/task.ts b/node/task.ts index 2e2927433..27409dcd6 100644 --- a/node/task.ts +++ b/node/task.ts @@ -987,6 +987,11 @@ export function cp(source: string, dest: string, options?: string, continueOnErr try { let isRecursive = options?.toLowerCase()?.includes('-r'); let isForce = options?.toLowerCase()?.includes('-f'); + + if (fs.lstatSync(source).isDirectory()) { + dest = path.join(dest, path.basename(source)); + } + fs.cpSync(source, dest, { recursive: isRecursive, force: isForce }); } catch (error) { debug('cp failed');