mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-26 13:03:37 +00:00
feat: add test for cleanup
This commit is contained in:
parent
f6ec85149b
commit
7b7ad1617b
7 changed files with 26002 additions and 42 deletions
37
dist/cleanup.js
vendored
37
dist/cleanup.js
vendored
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Retrieve environment variables and parameters
|
||||
const terraformCliPath = process.env.TERRAFORM_CLI_PATH;
|
||||
|
||||
// Function to recursively delete a directory
|
||||
const deleteDirectoryRecursive = function(directoryPath) {
|
||||
if (fs.existsSync(directoryPath)) {
|
||||
fs.readdirSync(directoryPath).forEach((file) => {
|
||||
const curPath = path.join(directoryPath, file);
|
||||
if (fs.lstatSync(curPath).isDirectory()) {
|
||||
// Recurse
|
||||
deleteDirectoryRecursive(curPath);
|
||||
} else {
|
||||
// Delete file
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(directoryPath);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Check if cleanup is required
|
||||
if (terraformCliPath) {
|
||||
console.log(`Cleaning up directory: ${terraformCliPath}`);
|
||||
deleteDirectoryRecursive(terraformCliPath);
|
||||
console.log('Cleanup completed.');
|
||||
} else {
|
||||
console.log('No cleanup required.');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue