1
0
Fork 0
mirror of https://github.com/actions/checkout.git synced 2025-03-28 11:00:05 +01:00

Do not delete cwd

This commit is contained in:
eric sciple 2019-12-03 13:15:48 -05:00
parent cc70598ce8
commit 1da0d665ed
2 changed files with 10 additions and 4 deletions

7
dist/index.js vendored
View file

@ -4978,8 +4978,11 @@ 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.
for (const file of yield fs.promises.readdir(settings.repositoryPath)) {
yield io.rmRF(settings.repositoryPath);
}
}
// Initialize the repository
if (!fsHelper.directoryExistsSync(path.join(settings.repositoryPath, '.git'))) {

View file

@ -59,8 +59,11 @@ 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.
for (const file of await fs.promises.readdir(settings.repositoryPath)) {
await io.rmRF(settings.repositoryPath)
}
}
// Initialize the repository