From ce4e3beff1ed33658f3160b0f45b688c6ea09932 Mon Sep 17 00:00:00 2001 From: Shohei Ueda <30958501+peaceiris@users.noreply.github.com> Date: Tue, 21 Jul 2020 12:53:14 +0900 Subject: [PATCH] fix: KeepFiles behaviour when DestinationDir has dir (#405) Related to #324 --- src/git-utils.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/git-utils.ts b/src/git-utils.ts index 97be11ee9..7f2e97eae 100644 --- a/src/git-utils.ts +++ b/src/git-utils.ts @@ -73,11 +73,23 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string): options ); if (result.exitcode === 0) { - process.chdir(workDir); - if (inps.KeepFiles) { - core.info('[INFO] Keep existing files'); + await createDir(destDir); + process.chdir(destDir); + + if (inps.DestinationDir !== '') { + if (inps.KeepFiles) { + core.info('[INFO] Keep existing files'); + } else { + core.info(`[INFO] clean up ${destDir}`); + await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']); + } } else { - await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']); + if (inps.KeepFiles) { + core.info('[INFO] Keep existing files'); + } else { + core.info(`[INFO] clean up ${destDir}`); + await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']); + } } await copyAssets(publishDir, destDir);