diff options
| author | eric sciple <ericsciple@users.noreply.github.com> | 2019-12-03 13:43:37 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-03 13:43:37 -0500 |
| commit | 269ab5656af46d784c439f7d2e226252d312f781 (patch) | |
| tree | 506f196d69b7928a085561d8fe45edfe68f985c0 | |
| parent | 889092a29248ed74165fe4c214e869941b83bea9 (diff) | |
Do not delete cwd (#86)
| -rw-r--r-- | dist/index.js | 8 | ||||
| -rw-r--r-- | src/git-source-provider.ts | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/dist/index.js b/dist/index.js index 0ea446b..4a1027b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4978,8 +4978,12 @@ function getSource(settings) { // Try prepare existing directory, otherwise recreate if (isExisting && !(yield tryPrepareExistingDirectory(git, settings.repositoryPath, repositoryUrl, settings.clean))) { - yield io.rmRF(settings.repositoryPath); - yield io.mkdirP(settings.repositoryPath); + // Delete the contents of the directory. Don't delete the directory itself + // since it may be the current working directory. + core.info(`Deleting the contents of '${settings.repositoryPath}'`); + for (const file of yield fs.promises.readdir(settings.repositoryPath)) { + yield io.rmRF(path.join(settings.repositoryPath, file)); + } } // Initialize the repository if (!fsHelper.directoryExistsSync(path.join(settings.repositoryPath, '.git'))) { diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 0752100..fc41fd2 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -59,8 +59,12 @@ export async function getSource(settings: ISourceSettings): Promise<void> { settings.clean )) ) { - await io.rmRF(settings.repositoryPath) - await io.mkdirP(settings.repositoryPath) + // Delete the contents of the directory. Don't delete the directory itself + // since it may be the current working directory. + core.info(`Deleting the contents of '${settings.repositoryPath}'`) + for (const file of await fs.promises.readdir(settings.repositoryPath)) { + await io.rmRF(path.join(settings.repositoryPath, file)) + } } // Initialize the repository |
