From 7da18744786006f50c9d340000dd3d168d8950ba Mon Sep 17 00:00:00 2001 From: Rafa Mel Date: Wed, 22 May 2019 02:04:15 +0200 Subject: [PATCH] fix(public/fs): correctly identifies skipped copies for !options.overwrite and destination is an exi --- src/public/fs/copy/copy.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/public/fs/copy/copy.ts b/src/public/fs/copy/copy.ts index 62c7b6c..ef94ef9 100644 --- a/src/public/fs/copy/copy.ts +++ b/src/public/fs/copy/copy.ts @@ -30,7 +30,12 @@ export async function each( }; const srcExist = await exists(src, { fail: options.fail }); - if (!srcExist) { + const skip = + !srcExist || + (!options.overwrite && + (await exists(dest)) && + (await fs.stat(dest).then((stat) => !stat.isDirectory()))); + if (skip) { log(options, 'info')( `Copy skipped: "${relatives.src}" to "${relatives.dest}"` );