Skip to content

Commit

Permalink
Add basename from source when it is a folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanduplenskikh committed Nov 14, 2024
1 parent 249ccf3 commit ab1654b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions node/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ab1654b

Please sign in to comment.